diff --git a/src/main/java/com/herobrine/mod/HerobrineMod.java b/src/main/java/com/herobrine/mod/HerobrineMod.java index 61876c54..a146d5ec 100644 --- a/src/main/java/com/herobrine/mod/HerobrineMod.java +++ b/src/main/java/com/herobrine/mod/HerobrineMod.java @@ -7,6 +7,7 @@ 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; @@ -14,12 +15,15 @@ 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; @@ -27,6 +31,7 @@ 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; @@ -76,7 +81,7 @@ public static void registerItems(@NotNull final RegistryEvent.Register 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")), @@ -108,7 +113,9 @@ public static void registerEntities(@NotNull final RegistryEvent.Register 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)); + } + } } } \ No newline at end of file diff --git a/src/main/java/com/herobrine/mod/blocks/HerobrineAlter.java b/src/main/java/com/herobrine/mod/blocks/HerobrineAlter.java index 0aef0129..429bf53d 100644 --- a/src/main/java/com/herobrine/mod/blocks/HerobrineAlter.java +++ b/src/main/java/com/herobrine/mod/blocks/HerobrineAlter.java @@ -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; @@ -143,24 +144,39 @@ 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; @@ -168,8 +184,7 @@ public ActionResultType onBlockActivated(@NotNull BlockState state, @NotNull Wor entity.sendMessage(new StringTextComponent(" 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 { diff --git a/src/main/java/com/herobrine/mod/client/renders/RenderRegistry.java b/src/main/java/com/herobrine/mod/client/renders/RenderRegistry.java index 651dfeaf..eb803e65 100644 --- a/src/main/java/com/herobrine/mod/client/renders/RenderRegistry.java +++ b/src/main/java/com/herobrine/mod/client/renders/RenderRegistry.java @@ -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; @@ -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) manager -> new SpriteRenderer(manager, Minecraft.getInstance().getItemRenderer())); - RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.UNHOLY_WATER_ENTITY, (IRenderFactory) 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()); diff --git a/src/main/java/com/herobrine/mod/entities/FakeHerobrineMageEntity.java b/src/main/java/com/herobrine/mod/entities/FakeHerobrineMageEntity.java index 16a8492b..35c3b01d 100644 --- a/src/main/java/com/herobrine/mod/entities/FakeHerobrineMageEntity.java +++ b/src/main/java/com/herobrine/mod/entities/FakeHerobrineMageEntity.java @@ -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)); diff --git a/src/main/java/com/herobrine/mod/entities/HerobrineBuilderEntity.java b/src/main/java/com/herobrine/mod/entities/HerobrineBuilderEntity.java index b4f454e4..93b8ca74 100644 --- a/src/main/java/com/herobrine/mod/entities/HerobrineBuilderEntity.java +++ b/src/main/java/com/herobrine/mod/entities/HerobrineBuilderEntity.java @@ -37,7 +37,7 @@ public HerobrineBuilderEntity(World worldIn) { this((EntityType) EntityRegistry.HEROBRINE_BUILDER_ENTITY, worldIn); } - private int placeTimer; + private int placeTimer = 1000; private int lifeTimer = 5100; @Override diff --git a/src/main/java/com/herobrine/mod/entities/HerobrineMageEntity.java b/src/main/java/com/herobrine/mod/entities/HerobrineMageEntity.java index cac3a54c..f196931d 100644 --- a/src/main/java/com/herobrine/mod/entities/HerobrineMageEntity.java +++ b/src/main/java/com/herobrine/mod/entities/HerobrineMageEntity.java @@ -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; @@ -32,15 +34,15 @@ public HerobrineMageEntity(World worldIn) { this((EntityType) 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)); @@ -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); + } + } } } } diff --git a/src/main/java/com/herobrine/mod/entities/HerobrineSpyEntity.java b/src/main/java/com/herobrine/mod/entities/HerobrineSpyEntity.java index a9191b8a..205af311 100644 --- a/src/main/java/com/herobrine/mod/entities/HerobrineSpyEntity.java +++ b/src/main/java/com/herobrine/mod/entities/HerobrineSpyEntity.java @@ -27,6 +27,8 @@ protected HerobrineSpyEntity(EntityType type, Worl experienceValue = 5; } + private int lifeTimer = 6000; + public HerobrineSpyEntity(World worldIn) { this((EntityType) EntityRegistry.HEROBRINE_SPY_ENTITY, worldIn); } @@ -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 @@ -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); } } \ No newline at end of file diff --git a/src/main/java/com/herobrine/mod/entities/HerobrineWarriorEntity.java b/src/main/java/com/herobrine/mod/entities/HerobrineWarriorEntity.java index d88acbd2..b9637788 100644 --- a/src/main/java/com/herobrine/mod/entities/HerobrineWarriorEntity.java +++ b/src/main/java/com/herobrine/mod/entities/HerobrineWarriorEntity.java @@ -1,8 +1,8 @@ package com.herobrine.mod.entities; import com.herobrine.mod.util.entities.EntityRegistry; -import com.herobrine.mod.util.savedata.Variables; import com.herobrine.mod.util.items.ItemList; +import com.herobrine.mod.util.savedata.Variables; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.entity.*; @@ -20,13 +20,16 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.*; +import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.IWorld; +import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; +import java.util.Objects; public class HerobrineWarriorEntity extends MonsterEntity{ - private int blockBreakCounter; + private int blockBreakCounter = 100; public HerobrineWarriorEntity(EntityType type, World worldIn) { super(type, worldIn); @@ -42,7 +45,7 @@ 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(3, new NearestAttackableTargetGoal<>(this, GolemEntity.class, true)); + this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, GolemEntity.class, false)); this.targetSelector.addGoal(4, new HurtByTargetGoal(this)); this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 0.4D)); this.goalSelector.addGoal(6, new LookAtGoal(this, PlayerEntity.class, 8.0F)); @@ -126,15 +129,19 @@ public void readAdditional(@NotNull CompoundNBT compound) { this.blockBreakCounter = compound.getInt("DestroyCooldown"); } - private boolean canReachTarget() { - return !this.getNavigator().noPath(); + private boolean unableToAttackTarget() { + if(this.getAttackTarget() != null) { + return this.getNavigator().noPath() && this.navigator.getPathToEntity(this.getAttackTarget(), 0) == null && !this.canAttack(this.getAttackTarget(), EntityPredicate.DEFAULT.setCustomPredicate(LivingEntity::attackable)); + } else { + return false; + } } @Override protected void updateAITasks() { if (this.blockBreakCounter > 0) { --this.blockBreakCounter; - if (this.blockBreakCounter == 0 && this.isAggressive() && this.canReachTarget() && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this)) { + if (this.blockBreakCounter == 0 && this.isAggressive() && this.unableToAttackTarget() && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this)) { int i1 = MathHelper.floor(this.getPosY()); int l1 = MathHelper.floor(this.getPosX()); int i2 = MathHelper.floor(this.getPosZ()); diff --git a/src/main/java/com/herobrine/mod/entities/HolyWaterEntity.java b/src/main/java/com/herobrine/mod/entities/HolyWaterEntity.java index 334e603c..5532bb14 100644 --- a/src/main/java/com/herobrine/mod/entities/HolyWaterEntity.java +++ b/src/main/java/com/herobrine/mod/entities/HolyWaterEntity.java @@ -1,25 +1,32 @@ package com.herobrine.mod.entities; import com.herobrine.mod.util.entities.EntityRegistry; -import net.minecraft.entity.Entity; +import com.herobrine.mod.util.items.ItemList; +import net.minecraft.block.HoneyBlock; import net.minecraft.entity.EntityType; +import net.minecraft.entity.IRendersAsItem; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.projectile.ProjectileItemEntity; import net.minecraft.entity.projectile.SnowballEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.particles.ParticleTypes; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.util.DamageSource; import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.EntityRayTraceResult; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import org.jetbrains.annotations.NotNull; -import java.util.Random; +import java.util.List; -public class HolyWaterEntity extends SnowballEntity{ - private static final Random random = new Random(); - - public HolyWaterEntity(EntityType entityType, World world) { +public class HolyWaterEntity extends SnowballEntity implements IRendersAsItem { + public HolyWaterEntity(EntityType entityType, World world) { super(entityType, world); } @@ -31,26 +38,41 @@ public HolyWaterEntity(World worldIn) { this((EntityType) EntityRegistry.HOLY_WATER_ENTITY, worldIn); } + @Override + @OnlyIn(Dist.CLIENT) + public @NotNull ItemStack getItem() { + return new ItemStack(ItemList.holy_water, 1); + } + @Override protected void onImpact(@NotNull RayTraceResult result) { - if (result.getType() == RayTraceResult.Type.ENTITY) { - Entity entity = ((EntityRayTraceResult)result).getEntity(); - ((LivingEntity) entity).clearActivePotions(); - ((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.REGENERATION, 300, 1)); - ((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.HEALTH_BOOST, 300, 1)); - entity.extinguish(); - entity.extinguish(); - int a = entity instanceof HerobrineWarriorEntity ? 12 : 0; - int b = entity instanceof HerobrineMageEntity ? 12 : 0; - int c = entity instanceof HerobrineSpyEntity ? 12 : 0; - int d = entity instanceof HerobrineBuilderEntity ? 12 : 0; - entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)a); - entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)b); - entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)c); - entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)d); - } if (!this.world.isRemote) { - this.playSound(SoundEvents.BLOCK_GLASS_BREAK, 0.8F, 0.9F / (random.nextFloat() * 0.4F + 0.8F)); + AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(1.0D, 1.0D, 1.0D); + List list = this.world.getEntitiesWithinAABB(LivingEntity.class, axisalignedbb); + if (!list.isEmpty()) { + for (LivingEntity entity : list) { + entity.clearActivePotions(); + entity.addPotionEffect(new EffectInstance(Effects.REGENERATION, 300, 1)); + entity.addPotionEffect(new EffectInstance(Effects.HEALTH_BOOST, 300, 1)); + entity.extinguish(); + if (entity instanceof HerobrineWarriorEntity) { + entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()),12.0F); + } + if (entity instanceof HerobrineMageEntity) { + entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()),12.0F); + } + if (entity instanceof HerobrineSpyEntity) { + entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()),12.0F); + } + if (entity instanceof HerobrineBuilderEntity) { + entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()),12.0F); + } + if (entity instanceof FakeHerobrineMageEntity) { + entity.remove(); + } + } + } + this.playSound(SoundEvents.BLOCK_GLASS_BREAK, 0.8F, 0.9F / (rand.nextFloat() * 0.4F + 0.8F)); this.world.setEntityState(this, (byte)3); this.remove(); } diff --git a/src/main/java/com/herobrine/mod/entities/InfectedChickenEntity.java b/src/main/java/com/herobrine/mod/entities/InfectedChickenEntity.java index fd6bcfb3..d9c6b0c9 100644 --- a/src/main/java/com/herobrine/mod/entities/InfectedChickenEntity.java +++ b/src/main/java/com/herobrine/mod/entities/InfectedChickenEntity.java @@ -3,9 +3,11 @@ 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; +import net.minecraft.entity.passive.MooshroomEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.DamageSource; @@ -14,12 +16,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.DifficultyInstance; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.*; import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; +import java.util.Random; public class InfectedChickenEntity extends MonsterEntity { public float wingRotation; diff --git a/src/main/java/com/herobrine/mod/entities/UnholyWaterEntity.java b/src/main/java/com/herobrine/mod/entities/UnholyWaterEntity.java index ed837e51..ace2ddef 100644 --- a/src/main/java/com/herobrine/mod/entities/UnholyWaterEntity.java +++ b/src/main/java/com/herobrine/mod/entities/UnholyWaterEntity.java @@ -1,25 +1,30 @@ package com.herobrine.mod.entities; import com.herobrine.mod.util.entities.EntityRegistry; +import com.herobrine.mod.util.items.ItemList; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.IRendersAsItem; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.projectile.SnowballEntity; +import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.util.DamageSource; import net.minecraft.util.SoundEvents; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.EntityRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import org.jetbrains.annotations.NotNull; +import java.util.List; import java.util.Random; -public class UnholyWaterEntity extends SnowballEntity{ - private static final Random random = new Random(); - - public UnholyWaterEntity(EntityType entityType, World world) { +public class UnholyWaterEntity extends SnowballEntity implements IRendersAsItem { + public UnholyWaterEntity(EntityType entityType, World world) { super(entityType, world); } @@ -31,21 +36,29 @@ public UnholyWaterEntity(World worldIn) { this((EntityType) EntityRegistry.UNHOLY_WATER_ENTITY, worldIn); } + @Override + @OnlyIn(Dist.CLIENT) + public @NotNull ItemStack getItem() { + return new ItemStack(ItemList.unholy_water, 1); + } + + @Override protected void onImpact(@NotNull RayTraceResult result) { - if (result.getType() == RayTraceResult.Type.ENTITY) { - Entity entity = ((EntityRayTraceResult)result).getEntity(); - ((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.WITHER, 300, 1)); - ((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.HUNGER, 300, 1)); - entity.setFire(15); - int i = 4; - entity.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this, this.getThrower()), (float)i); - } if (!this.world.isRemote) { - this.playSound(SoundEvents.BLOCK_GLASS_BREAK, 0.8F, 0.9F / (random.nextFloat() * 0.4F + 0.8F)); + AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(1.0D, 1.0D, 1.0D); + List list = this.world.getEntitiesWithinAABB(LivingEntity.class, axisalignedbb); + if (!list.isEmpty()) { + for (LivingEntity entity : list) { + entity.addPotionEffect(new EffectInstance(Effects.WITHER, 300, 1)); + entity.addPotionEffect(new EffectInstance(Effects.HUNGER, 300, 1)); + entity.setFire(15); + entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()),4.0F); + } + } + this.playSound(SoundEvents.BLOCK_GLASS_BREAK, 0.8F, 0.9F / (rand.nextFloat() * 0.4F + 0.8F)); this.world.setEntityState(this, (byte)3); this.remove(); } - } } \ No newline at end of file diff --git a/src/main/java/com/herobrine/mod/util/entities/EntityRegistry.java b/src/main/java/com/herobrine/mod/util/entities/EntityRegistry.java index 99be8a55..61f2ab4e 100644 --- a/src/main/java/com/herobrine/mod/util/entities/EntityRegistry.java +++ b/src/main/java/com/herobrine/mod/util/entities/EntityRegistry.java @@ -120,17 +120,17 @@ public static void registerEntityWorldSpawns() { for (BiomeDictionary.Type t : InfectedVillagerTypes) { Set biomes = BiomeDictionary.getBiomes(t); for (Biome currentBiome : biomes) { - currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_VILLAGER_ENTITY, 5, 1, 4)); + currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_VILLAGER_ENTITY, 3, 1, 4)); } } for (BiomeDictionary.Type t : InfectedAnimalTypes) { Set biomes = BiomeDictionary.getBiomes(t); for (Biome currentBiome : biomes) { - currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_PIG_ENTITY, 7, 3, 6)); - currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_COW_ENTITY, 7, 2, 4)); - currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_CHICKEN_ENTITY, 7, 4, 8)); - currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_SHEEP_ENTITY, 7, 3, 6)); + currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_PIG_ENTITY, 4, 3, 6)); + currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_COW_ENTITY, 4, 2, 4)); + currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_CHICKEN_ENTITY, 4, 4, 8)); + currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_SHEEP_ENTITY, 4, 3, 6)); } } @@ -139,7 +139,7 @@ public static void registerEntityWorldSpawns() { for (Biome currentBiome : biomes) { currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(HEROBRINE_BUILDER_ENTITY, 1, 1, 1)); currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(HEROBRINE_MAGE_ENTITY, 1, 1, 1)); - currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(HEROBRINE_SPY_ENTITY, 3, 1, 1)); + currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(HEROBRINE_SPY_ENTITY, 1, 1, 1)); currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(HEROBRINE_WARRIOR_ENTITY, 1, 1, 1)); currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(INFECTED_MOOSHROOM_ENTITY, 1, 1, 1)); } @@ -150,7 +150,7 @@ public static void registerEntityWorldSpawns() { for (Biome currentBiome : biomes) { currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(HEROBRINE_BUILDER_ENTITY, 1, 1, 1)); currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(HEROBRINE_MAGE_ENTITY, 1, 1, 1)); - currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(HEROBRINE_SPY_ENTITY, 1, 1, 1)); + currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(HEROBRINE_SPY_ENTITY, 2, 1, 1)); currentBiome.getSpawns(EntityClassification.MONSTER).add(new Biome.SpawnListEntry(HEROBRINE_WARRIOR_ENTITY, 1, 1, 1)); } } diff --git a/src/main/java/com/herobrine/mod/util/items/ItemTierList.java b/src/main/java/com/herobrine/mod/util/items/ItemTierList.java index 8692a56f..d3359a10 100644 --- a/src/main/java/com/herobrine/mod/util/items/ItemTierList.java +++ b/src/main/java/com/herobrine/mod/util/items/ItemTierList.java @@ -10,9 +10,12 @@ public enum ItemTierList implements IItemTier { bedrock_item_tier(9.0f, -1.0f, -1, -1, -1, Items.BEDROCK), cursed_diamond_item_tier(4.0f, 9.0f, 1600, 4, 22, ItemList.cursed_diamond); - private float attackDamage, efficiency; - private int maxUses, harvestLevel, enchantability; - private Item repairMaterial; + private final float attackDamage; + private final float efficiency; + private final int maxUses; + private final int harvestLevel; + private final int enchantability; + private final Item repairMaterial; ItemTierList(float attackDamage, float efficiency, int maxUses, int harvestLevel, int enchantability, Item repairMaterial) { this.attackDamage = attackDamage; diff --git a/src/main/java/com/herobrine/mod/util/savedata/Variables.java b/src/main/java/com/herobrine/mod/util/savedata/Variables.java index a5bff2e4..bb7bd2fd 100644 --- a/src/main/java/com/herobrine/mod/util/savedata/Variables.java +++ b/src/main/java/com/herobrine/mod/util/savedata/Variables.java @@ -26,14 +26,12 @@ public static class WorldVariables extends WorldSavedData { public WorldVariables() { super(DATA_NAME); - this.addNetworkMessage(Variables.WorldSavedDataSyncMessage.class, Variables.WorldSavedDataSyncMessage::buffer, - Variables.WorldSavedDataSyncMessage::new, Variables.WorldSavedDataSyncMessage::handler); + this.addNetworkMessage(Variables.WorldSavedDataSyncMessage.class, Variables.WorldSavedDataSyncMessage::buffer, Variables.WorldSavedDataSyncMessage::new, Variables.WorldSavedDataSyncMessage::handler); } private int messageID = 0; - public void addNetworkMessage(Class messageType, BiConsumer encoder, Function decoder, - BiConsumer> messageConsumer) { + public void addNetworkMessage(Class messageType, BiConsumer encoder, Function decoder, BiConsumer> messageConsumer) { HerobrineMod.PACKET_HANDLER.registerMessage(messageID, messageType, encoder, decoder, messageConsumer); messageID++; } diff --git a/src/main/java/com/herobrine/mod/worldgen/structures/TrappedHouse.java b/src/main/java/com/herobrine/mod/worldgen/structures/TrappedHouse.java index 4f93bd2d..bb8774b3 100644 --- a/src/main/java/com/herobrine/mod/worldgen/structures/TrappedHouse.java +++ b/src/main/java/com/herobrine/mod/worldgen/structures/TrappedHouse.java @@ -8,8 +8,8 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; +import net.minecraft.world.World; import net.minecraft.world.biome.Biome; -import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.ChunkGenerator; import net.minecraft.world.gen.GenerationStage; import net.minecraft.world.gen.Heightmap; @@ -34,13 +34,7 @@ public static void registerStructure() { public boolean place(@NotNull IWorld iworld, @NotNull ChunkGenerator generator, @NotNull Random random, @NotNull BlockPos pos, @NotNull NoFeatureConfig config) { int ci = pos.getX(); int ck = pos.getZ(); - DimensionType dimensionType = iworld.getDimension().getType(); - boolean dimensionCriteria = false; - if (dimensionType == DimensionType.OVERWORLD) - dimensionCriteria = true; - if (!dimensionCriteria) - return false; - if ((random.nextInt(1000000) + 1) <= 500) { + if ((random.nextInt(1000000) + 1) <= 750) { int count = random.nextInt(1) + 1; for (int a = 0; a < count; a++) { int i = ci + random.nextInt(16) + 8;