Skip to content

Commit

Permalink
Updated to 0.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-MacLean authored May 16, 2020
1 parent 45c3db6 commit 9c3338f
Show file tree
Hide file tree
Showing 15 changed files with 204 additions and 98 deletions.
29 changes: 27 additions & 2 deletions src/main/java/com/herobrine/mod/HerobrineMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@
import com.herobrine.mod.util.items.ArmorMaterialList;
import com.herobrine.mod.util.items.ItemList;
import com.herobrine.mod.util.items.ItemTierList;
import com.herobrine.mod.util.savedata.Variables;
import com.herobrine.mod.util.worldgen.BiomeInit;
import com.herobrine.mod.worldgen.structures.TrappedHouse;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.block.material.PushReaction;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.*;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.storage.WorldSavedData;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.PacketDistributor;
import net.minecraftforge.fml.network.simple.SimpleChannel;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -76,7 +81,7 @@ public static void registerItems(@NotNull final RegistryEvent.Register<Item> eve
ItemList.cursed_diamond_axe = new AxeItem(ItemTierList.cursed_diamond_item_tier, 5, -3.0f, new Item.Properties().group(ItemGroup.TOOLS)).setRegistryName(location("cursed_diamond_axe")),
ItemList.cursed_diamond_pickaxe = new PickaxeItem(ItemTierList.cursed_diamond_item_tier, 1, -2.8f, new Item.Properties().group(ItemGroup.TOOLS)).setRegistryName(location("cursed_diamond_pickaxe")),
ItemList.cursed_diamond_shovel = new ShovelItem(ItemTierList.cursed_diamond_item_tier, 1.5f, -3.0f, new Item.Properties().group(ItemGroup.TOOLS)).setRegistryName(location("cursed_diamond_shovel")),
ItemList.cursed_diamond_hoe = new HoeItem(ItemTierList.cursed_diamond_item_tier, 0.0F, new Item.Properties().group(ItemGroup.TOOLS)).setRegistryName(location("cursed_diamond_hoe")),
ItemList.cursed_diamond_hoe = new HoeItem(ItemTierList.cursed_diamond_item_tier, 1.0F, new Item.Properties().group(ItemGroup.TOOLS)).setRegistryName(location("cursed_diamond_hoe")),
ItemList.cursed_diamond_helmet = new ArmorItem(ArmorMaterialList.cursed_diamond_armor_material, EquipmentSlotType.HEAD, new Item.Properties().group(ItemGroup.COMBAT)).setRegistryName(location("cursed_diamond_helmet")),
ItemList.cursed_diamond_chestplate = new ArmorItem(ArmorMaterialList.cursed_diamond_armor_material, EquipmentSlotType.CHEST, new Item.Properties().group(ItemGroup.COMBAT)).setRegistryName(location("cursed_diamond_chestplate")),
ItemList.cursed_diamond_leggings = new ArmorItem(ArmorMaterialList.cursed_diamond_armor_material, EquipmentSlotType.LEGS, new Item.Properties().group(ItemGroup.COMBAT)).setRegistryName(location("cursed_diamond_leggings")),
Expand Down Expand Up @@ -108,7 +113,9 @@ public static void registerEntities(@NotNull final RegistryEvent.Register<Entity
EntityRegistry.HEROBRINE_SPY_ENTITY,
EntityRegistry.HEROBRINE_BUILDER_ENTITY,
EntityRegistry.HEROBRINE_MAGE_ENTITY,
EntityRegistry.FAKE_HEROBRINE_MAGE_ENTITY
EntityRegistry.FAKE_HEROBRINE_MAGE_ENTITY,
EntityRegistry.HOLY_WATER_ENTITY,
EntityRegistry.UNHOLY_WATER_ENTITY
);
EntityRegistry.registerEntityWorldSpawns();
}
Expand All @@ -117,5 +124,23 @@ public static void registerEntities(@NotNull final RegistryEvent.Register<Entity
public static void registerBiomes(@NotNull final RegistryEvent.Register<Biome> event) {
BiomeInit.registerBiomes();
}

@SubscribeEvent
public void onPlayerLoggedIn(PlayerEvent.@NotNull PlayerLoggedInEvent event) {
if (!event.getPlayer().world.isRemote) {
WorldSavedData worlddata = Variables.WorldVariables.get(event.getPlayer().world);
if (worlddata != null)
HerobrineMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) event.getPlayer()), new Variables.WorldSavedDataSyncMessage(1, worlddata));
}
}

@SubscribeEvent
public void onPlayerChangedDimension(PlayerEvent.@NotNull PlayerChangedDimensionEvent event) {
if (!event.getPlayer().world.isRemote) {
WorldSavedData worlddata = Variables.WorldVariables.get(event.getPlayer().world);
if (worlddata != null)
HerobrineMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) event.getPlayer()), new Variables.WorldSavedDataSyncMessage(1, worlddata));
}
}
}
}
27 changes: 21 additions & 6 deletions src/main/java/com/herobrine/mod/blocks/HerobrineAlter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.fluid.IFluidState;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.pathfinding.PathType;
import net.minecraft.state.BooleanProperty;
Expand Down Expand Up @@ -143,33 +144,47 @@ public void animateTick(@NotNull BlockState stateIn, @NotNull World worldIn, @No
}
}

@Override
public boolean hasComparatorInputOverride(@NotNull BlockState state) {
return true;
}

@Override
public int getComparatorInputOverride(@NotNull BlockState blockState, @NotNull World worldIn, @NotNull BlockPos pos) {
return blockState.get(ModBlockStates.ACTIVE) ? 15 : 0;
}

@NotNull
@Override
public ActionResultType onBlockActivated(@NotNull BlockState state, @NotNull World world, @NotNull BlockPos pos, @NotNull PlayerEntity entity, @NotNull Hand hand, @NotNull BlockRayTraceResult hit) {
Variables.WorldVariables.get(world).syncData(world);
boolean i = state.get(ModBlockStates.ACTIVE);
if (i == Boolean.FALSE) {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
if (entity.inventory.hasItemStack(new ItemStack(ItemList.cursed_diamond, 1))) {
ItemStack itemstack = entity.getHeldItem(hand);
if (itemstack.getItem() == ItemList.cursed_diamond) {
assert false;
state = state.getBlockState().with(ModBlockStates.ACTIVE, Boolean.TRUE);
if (entity instanceof PlayerEntity && !entity.abilities.isCreativeMode)
entity.inventory.clearMatchingItems(p -> new ItemStack(ItemList.cursed_diamond, 1).getItem() == p.getItem(), 1);
if (entity instanceof PlayerEntity && !entity.abilities.isCreativeMode) {
itemstack.shrink(1);
}
world.setBlockState(pos, state, 2);
if (state.get(WATERLOGGED)) {
world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}

if (world instanceof ServerWorld) {
((ServerWorld) world).addLightningBolt(new LightningBoltEntity(world, x, y, z, false));
}
if (!(Variables.WorldVariables.get(world).Spawn)) {
if (((entity instanceof PlayerEntity) && entity.inventory.hasItemStack(new ItemStack(ItemList.cursed_diamond, 1))) && (!(Variables.WorldVariables.get(world).Spawn))) {
assert false;
if(world.isRemote) {
entity.sendMessage(new StringTextComponent("<Herobrine> You have no idea what you have done!"));
}
Variables.WorldVariables.get(world).Spawn = true;
if (world instanceof ServerWorld)
((ServerWorld) world).addLightningBolt(new LightningBoltEntity(world, x, y, z, false));
Variables.WorldVariables.get(world).syncData(world);
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.herobrine.mod.client.renders;

import com.herobrine.mod.entities.HolyWaterEntity;
import com.herobrine.mod.util.entities.EntityRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.SpriteRenderer;
Expand All @@ -13,8 +14,8 @@
public class RenderRegistry {
public static void registerEntityRenders() {
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.HEROBRINE_WARRIOR_ENTITY, new HerobrineWarriorEntityRender.RenderFactory());
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.HOLY_WATER_ENTITY, (IRenderFactory<Entity>) manager -> new SpriteRenderer(manager, Minecraft.getInstance().getItemRenderer()));
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.UNHOLY_WATER_ENTITY, (IRenderFactory<Entity>) manager -> new SpriteRenderer(manager, Minecraft.getInstance().getItemRenderer()));
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.HOLY_WATER_ENTITY, renderManager -> new SpriteRenderer(renderManager, Minecraft.getInstance().getItemRenderer()));
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.UNHOLY_WATER_ENTITY, renderManager -> new SpriteRenderer(renderManager, Minecraft.getInstance().getItemRenderer()));
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_PIG_ENTITY, new InfectedPigEntityRender.RenderFactory());
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_CHICKEN_ENTITY, new InfectedChickenEntityRender.RenderFactory());
RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_SHEEP_ENTITY, new InfectedSheepEntityRender.RenderFactory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public FakeHerobrineMageEntity(World worldIn) {
protected void registerGoals() {
this.goalSelector.addGoal(0, new SwimGoal(this));
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 0.6D, true));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, false));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, GolemEntity.class, true));
this.targetSelector.addGoal(4, new HurtByTargetGoal(this));
this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 0.4D));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public HerobrineBuilderEntity(World worldIn) {
this((EntityType<? extends HerobrineBuilderEntity>) EntityRegistry.HEROBRINE_BUILDER_ENTITY, worldIn);
}

private int placeTimer;
private int placeTimer = 1000;
private int lifeTimer = 5100;

@Override
Expand Down
37 changes: 21 additions & 16 deletions src/main/java/com/herobrine/mod/entities/HerobrineMageEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.herobrine.mod.util.entities.EntityRegistry;
import com.herobrine.mod.util.savedata.Variables;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.monster.MonsterEntity;
Expand Down Expand Up @@ -32,15 +34,15 @@ public HerobrineMageEntity(World worldIn) {
this((EntityType<? extends HerobrineMageEntity>) EntityRegistry.HEROBRINE_MAGE_ENTITY, worldIn);
}

private int illusionCastingTime;
private int effectsCastingTime;
private int teleportCastingTime;
private int illusionCastingTime = 400;
private int effectsCastingTime = 250;
private int teleportCastingTime = 500;

@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new SwimGoal(this));
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 0.6D, true));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, false));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, GolemEntity.class, true));
this.targetSelector.addGoal(4, new HurtByTargetGoal(this));
this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 0.4D));
Expand Down Expand Up @@ -242,18 +244,21 @@ public void livingTick() {
int x = (int) entity.getPosX();
int y = (int) entity.getPosY();
int z = (int) entity.getPosZ();
entity.setPositionAndUpdate(x, y + 4, z);
}
if (this.world.isRemote) {
if (!this.isSilent()) {
this.world.playSound(this.getPosX() + 0.5D, this.getPosY() + 0.5D, this.getPosZ() + 0.5D, SoundEvents.ENTITY_ILLUSIONER_CAST_SPELL, this.getSoundCategory(), 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F, false);
}

for (int i = 0; i < 20; ++i) {
double d0 = this.rand.nextGaussian() * 0.02D;
double d1 = this.rand.nextGaussian() * 0.02D;
double d2 = this.rand.nextGaussian() * 0.02D;
this.world.addParticle(ParticleTypes.EFFECT, this.getPosXWidth(1.0D) - d0 * 10.0D, this.getPosYRandom() - d1 * 10.0D, this.getPosZRandom(1.0D) - d2 * 10.0D, d0, d1, d2);
BlockState block = world.getBlockState(new BlockPos(x, y + 3, z));
BlockState blockAt = world.getBlockState(new BlockPos(x, y + 4, z));
if (blockAt.getBlock() == Blocks.AIR.getDefaultState().getBlock() && block.getBlock() == Blocks.AIR.getDefaultState().getBlock() || blockAt.getBlock() == Blocks.CAVE_AIR.getDefaultState().getBlock() && block.getBlock() == Blocks.CAVE_AIR.getDefaultState().getBlock() || blockAt.getBlock() == Blocks.CAVE_AIR.getDefaultState().getBlock() && block.getBlock() == Blocks.AIR.getDefaultState().getBlock() || blockAt.getBlock() == Blocks.AIR.getDefaultState().getBlock() && block.getBlock() == Blocks.CAVE_AIR.getDefaultState().getBlock()) {
entity.setPositionAndUpdate(x, y + 4, z);
if (this.world.isRemote) {
if (!this.isSilent()) {
this.world.playSound(this.getPosX() + 0.5D, this.getPosY() + 0.5D, this.getPosZ() + 0.5D, SoundEvents.ENTITY_ILLUSIONER_CAST_SPELL, this.getSoundCategory(), 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F, false);
}
for (int i = 0; i < 20; ++i) {
double d0 = this.rand.nextGaussian() * 0.02D;
double d1 = this.rand.nextGaussian() * 0.02D;
double d2 = this.rand.nextGaussian() * 0.02D;
this.world.addParticle(ParticleTypes.EFFECT, this.getPosXWidth(1.0D) - d0 * 10.0D, this.getPosYRandom() - d1 * 10.0D, this.getPosZRandom(1.0D) - d2 * 10.0D, d0, d1, d2);
}
}
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/herobrine/mod/entities/HerobrineSpyEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ protected HerobrineSpyEntity(EntityType<? extends HerobrineSpyEntity> type, Worl
experienceValue = 5;
}

private int lifeTimer = 6000;

public HerobrineSpyEntity(World worldIn) {
this((EntityType<? extends HerobrineSpyEntity>) EntityRegistry.HEROBRINE_SPY_ENTITY, worldIn);
}
Expand Down Expand Up @@ -105,10 +107,29 @@ public boolean attackEntityFrom(@NotNull DamageSource source, float amount) {
return super.attackEntityFrom(source, amount);
}

@Override
public void writeAdditional(@NotNull CompoundNBT compound) {
super.writeAdditional(compound);
compound.putInt("LifeTime", this.lifeTimer);
}

@Override
public void readAdditional(@NotNull CompoundNBT compound) {
super.readAdditional(compound);
this.lifeTimer = compound.getInt("LifeTime");
}

@Override
public void baseTick() {
super.baseTick();
this.clearActivePotions();
--this.lifeTimer;
if(this.lifeTimer > 6000) {
this.lifeTimer = 6000;
}
if(this.lifeTimer <= 0) {
this.remove();
}
}

@Override
Expand All @@ -117,6 +138,7 @@ public ILivingEntityData onInitialSpawn(@NotNull IWorld worldIn, @NotNull Diffic
if ((!(Variables.WorldVariables.get(world).Spawn))) {
this.remove();
}
this.enablePersistence();
return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag);
}
}
Loading

0 comments on commit 9c3338f

Please sign in to comment.