diff --git a/src/main/java/com/herobrine/mod/HerobrineMod.java b/src/main/java/com/herobrine/mod/HerobrineMod.java index 754478eb..17990a87 100644 --- a/src/main/java/com/herobrine/mod/HerobrineMod.java +++ b/src/main/java/com/herobrine/mod/HerobrineMod.java @@ -107,7 +107,8 @@ public static void registerEntities(@NotNull final RegistryEvent.Register> { + private static final Map field_217774_a = Util.make(Maps.newHashMap(), (p_217773_0_) -> { + p_217773_0_.put(InfectedMooshroomEntity.Type.BROWN, HerobrineMod.location("textures/entity/infected_brown_mooshroom.png")); + p_217773_0_.put(InfectedMooshroomEntity.Type.RED, HerobrineMod.location("textures/entity/infected_red_mooshroom.png")); + }); + + public InfectedMooshroomEntityRender(EntityRendererManager renderManagerIn) { + super(renderManagerIn, new CowModel<>(), 0.7F); + this.addLayer(new InfectedMooshroomMushroomLayer<>(this)); + } + + @NotNull + public ResourceLocation getEntityTexture(@NotNull InfectedMooshroomEntity entity) { + return field_217774_a.get(entity.getMooshroomType()); + } + + public static class RenderFactory implements IRenderFactory { + @Override + public EntityRenderer createRenderFor(EntityRendererManager manager) { + return new InfectedMooshroomEntityRender(manager); + } + } +} \ No newline at end of file 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 b72748f0..f7c91f5e 100644 --- a/src/main/java/com/herobrine/mod/client/renders/RenderRegistry.java +++ b/src/main/java/com/herobrine/mod/client/renders/RenderRegistry.java @@ -19,5 +19,6 @@ public static void registerEntityRenders() { RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_CHICKEN_ENTITY, new InfectedChickenEntityRender.RenderFactory()); RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_SHEEP_ENTITY, new InfectedSheepEntityRender.RenderFactory()); RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_COW_ENTITY, new InfectedCowEntityRender.RenderFactory()); + RenderingRegistry.registerEntityRenderingHandler(EntityRegistry.INFECTED_MOOSHROOM_ENTITY, new InfectedMooshroomEntityRender.RenderFactory()); } } \ No newline at end of file diff --git a/src/main/java/com/herobrine/mod/client/renders/layers/InfectedMooshroomMushroomLayer.java b/src/main/java/com/herobrine/mod/client/renders/layers/InfectedMooshroomMushroomLayer.java new file mode 100644 index 00000000..37444fb8 --- /dev/null +++ b/src/main/java/com/herobrine/mod/client/renders/layers/InfectedMooshroomMushroomLayer.java @@ -0,0 +1,55 @@ +package com.herobrine.mod.client.renders.layers; + +import com.herobrine.mod.entities.InfectedMooshroomEntity; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.block.BlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.Vector3f; +import net.minecraft.client.renderer.entity.IEntityRenderer; +import net.minecraft.client.renderer.entity.LivingRenderer; +import net.minecraft.client.renderer.entity.layers.LayerRenderer; +import net.minecraft.client.renderer.entity.model.CowModel; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import org.jetbrains.annotations.NotNull; + +@OnlyIn(Dist.CLIENT) +public class InfectedMooshroomMushroomLayer extends LayerRenderer> { + public InfectedMooshroomMushroomLayer(IEntityRenderer> rendererIn) { + super(rendererIn); + } + + public void render(@NotNull MatrixStack matrixStackIn, @NotNull IRenderTypeBuffer bufferIn, int packedLightIn, @NotNull T entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { + if (!entitylivingbaseIn.isChild() && !entitylivingbaseIn.isInvisible()) { + BlockRendererDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); + BlockState blockstate = entitylivingbaseIn.getMooshroomType().getRenderState(); + int i = LivingRenderer.getPackedOverlay(entitylivingbaseIn, 0.0F); + matrixStackIn.push(); + matrixStackIn.translate(0.2F, -0.35F, 0.5D); + matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-48.0F)); + matrixStackIn.scale(-1.0F, -1.0F, 1.0F); + matrixStackIn.translate(-0.5D, -0.5D, -0.5D); + blockrendererdispatcher.renderBlock(blockstate, matrixStackIn, bufferIn, packedLightIn, i); + matrixStackIn.pop(); + matrixStackIn.push(); + matrixStackIn.translate(0.2F, -0.35F, 0.5D); + matrixStackIn.rotate(Vector3f.YP.rotationDegrees(42.0F)); + matrixStackIn.translate(0.1F, 0.0D, -0.6F); + matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-48.0F)); + matrixStackIn.scale(-1.0F, -1.0F, 1.0F); + matrixStackIn.translate(-0.5D, -0.5D, -0.5D); + blockrendererdispatcher.renderBlock(blockstate, matrixStackIn, bufferIn, packedLightIn, i); + matrixStackIn.pop(); + matrixStackIn.push(); + this.getEntityModel().getHead().translateRotate(matrixStackIn); + matrixStackIn.translate(0.0D, -0.7F, -0.2F); + matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-78.0F)); + matrixStackIn.scale(-1.0F, -1.0F, 1.0F); + matrixStackIn.translate(-0.5D, -0.5D, -0.5D); + blockrendererdispatcher.renderBlock(blockstate, matrixStackIn, bufferIn, packedLightIn, i); + matrixStackIn.pop(); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/herobrine/mod/entities/HerobrineEntity.java b/src/main/java/com/herobrine/mod/entities/HerobrineEntity.java index 0361a44a..fee536cd 100644 --- a/src/main/java/com/herobrine/mod/entities/HerobrineEntity.java +++ b/src/main/java/com/herobrine/mod/entities/HerobrineEntity.java @@ -1,7 +1,7 @@ package com.herobrine.mod.entities; import com.herobrine.mod.util.entities.EntityRegistry; -import com.herobrine.mod.util.entities.GenericSummoningRequiredEntityOnUpdateTick; +import com.herobrine.mod.util.entities.SummoningEntitySpawnSettings; import com.herobrine.mod.util.entities.HerobrineEntityOnUpdateTick; import com.herobrine.mod.util.misc.Variables; import com.herobrine.mod.util.items.ItemList; @@ -14,7 +14,6 @@ import net.minecraft.entity.projectile.PotionEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockPos; @@ -160,22 +159,27 @@ public boolean attackEntityAsMob(Entity entityIn) { return flag; } - @Override - public void baseTick() { + @Override + public void baseTick() { super.baseTick(); Entity entity = this; { - Variables.WorldVariables.get(world).syncData(world); java.util.HashMap $_dependencies = new java.util.HashMap<>(); $_dependencies.put("entity", entity); - $_dependencies.put("world", world); - GenericSummoningRequiredEntityOnUpdateTick.executeProcedure($_dependencies); HerobrineEntityOnUpdateTick.executeProcedure($_dependencies); } } @Override public ILivingEntityData onInitialSpawn(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) { + Entity entity = this; + { + Variables.WorldVariables.get(world).syncData(world); + java.util.HashMap $_dependencies = new java.util.HashMap<>(); + $_dependencies.put("entity", entity); + $_dependencies.put("world", world); + SummoningEntitySpawnSettings.executeProcedure($_dependencies); + } spawnDataIn = super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); this.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(ItemList.bedrock_sword)); this.inventoryHandsDropChances[EquipmentSlotType.MAINHAND.getIndex()] = 0.0F; diff --git a/src/main/java/com/herobrine/mod/entities/InfectedChickenEntity.java b/src/main/java/com/herobrine/mod/entities/InfectedChickenEntity.java index ae3747c4..a98ff835 100644 --- a/src/main/java/com/herobrine/mod/entities/InfectedChickenEntity.java +++ b/src/main/java/com/herobrine/mod/entities/InfectedChickenEntity.java @@ -1,24 +1,27 @@ package com.herobrine.mod.entities; import com.herobrine.mod.util.entities.EntityRegistry; -import com.herobrine.mod.util.entities.GenericSummoningRequiredEntityOnUpdateTick; +import com.herobrine.mod.util.entities.SummoningEntitySpawnSettings; import com.herobrine.mod.util.misc.Variables; import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.*; import net.minecraft.entity.ai.goal.*; import net.minecraft.entity.monster.MonsterEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.DamageSource; import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvents; 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 org.jetbrains.annotations.NotNull; +import javax.annotation.Nullable; + public class InfectedChickenEntity extends MonsterEntity { public float wingRotation; public float destPos; @@ -84,16 +87,16 @@ public void livingTick() { } @Override - public void baseTick() { - super.baseTick(); + public ILivingEntityData onInitialSpawn(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) { Entity entity = this; { Variables.WorldVariables.get(world).syncData(world); java.util.HashMap $_dependencies = new java.util.HashMap<>(); $_dependencies.put("entity", entity); $_dependencies.put("world", world); - GenericSummoningRequiredEntityOnUpdateTick.executeProcedure($_dependencies); + SummoningEntitySpawnSettings.executeProcedure($_dependencies); } + return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); } @Override diff --git a/src/main/java/com/herobrine/mod/entities/InfectedCowEntity.java b/src/main/java/com/herobrine/mod/entities/InfectedCowEntity.java index 0df3e769..fc21e716 100644 --- a/src/main/java/com/herobrine/mod/entities/InfectedCowEntity.java +++ b/src/main/java/com/herobrine/mod/entities/InfectedCowEntity.java @@ -1,25 +1,28 @@ package com.herobrine.mod.entities; import com.herobrine.mod.util.entities.EntityRegistry; -import com.herobrine.mod.util.entities.GenericSummoningRequiredEntityOnUpdateTick; +import com.herobrine.mod.util.entities.SummoningEntitySpawnSettings; import com.herobrine.mod.util.misc.Variables; import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.*; import net.minecraft.entity.ai.goal.*; import net.minecraft.entity.monster.MonsterEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.DamageSource; import net.minecraft.util.Hand; import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.IWorld; import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; +import javax.annotation.Nullable; + public class InfectedCowEntity extends MonsterEntity { public InfectedCowEntity(EntityType type, World worldIn) { super(type, worldIn); @@ -59,16 +62,16 @@ public boolean attackEntityFrom(@NotNull DamageSource source, float amount) { } @Override - public void baseTick() { - super.baseTick(); + public ILivingEntityData onInitialSpawn(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) { Entity entity = this; { Variables.WorldVariables.get(world).syncData(world); java.util.HashMap $_dependencies = new java.util.HashMap<>(); $_dependencies.put("entity", entity); $_dependencies.put("world", world); - GenericSummoningRequiredEntityOnUpdateTick.executeProcedure($_dependencies); + SummoningEntitySpawnSettings.executeProcedure($_dependencies); } + return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); } @Override diff --git a/src/main/java/com/herobrine/mod/entities/InfectedMooshroomEntity.java b/src/main/java/com/herobrine/mod/entities/InfectedMooshroomEntity.java new file mode 100644 index 00000000..00c3edda --- /dev/null +++ b/src/main/java/com/herobrine/mod/entities/InfectedMooshroomEntity.java @@ -0,0 +1,193 @@ +package com.herobrine.mod.entities; + +import com.herobrine.mod.util.entities.EntityRegistry; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FlowerBlock; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.effect.LightningBoltEntity; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.passive.CowEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.SuspiciousStewItem; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.datasync.DataParameter; +import net.minecraft.network.datasync.DataSerializers; +import net.minecraft.network.datasync.EntityDataManager; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.potion.Effect; +import net.minecraft.tags.ItemTags; +import net.minecraft.util.Hand; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.SoundEvents; +import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +public class InfectedMooshroomEntity extends InfectedCowEntity implements net.minecraftforge.common.IShearable { + private static final DataParameter MOOSHROOM_TYPE = EntityDataManager.createKey(InfectedMooshroomEntity.class, DataSerializers.STRING); + private Effect hasStewEffect; + private int effectDuration; + private UUID lightningUUID; + + public InfectedMooshroomEntity(EntityType type, World worldIn) { + super(type, worldIn); + experienceValue = 3; + } + + public InfectedMooshroomEntity(World worldIn) { + this((EntityType) EntityRegistry.INFECTED_MOOSHROOM_ENTITY, worldIn); + } + + @Override + public void onStruckByLightning(@NotNull LightningBoltEntity lightningBolt) { + UUID uuid = lightningBolt.getUniqueID(); + if (!uuid.equals(this.lightningUUID)) { + this.setMooshroomType(this.getMooshroomType() == InfectedMooshroomEntity.Type.RED ? InfectedMooshroomEntity.Type.BROWN : InfectedMooshroomEntity.Type.RED); + this.lightningUUID = uuid; + this.playSound(SoundEvents.ENTITY_MOOSHROOM_CONVERT, 2.0F, 1.0F); + } + + } + + @Override + protected void registerData() { + super.registerData(); + this.dataManager.register(MOOSHROOM_TYPE, InfectedMooshroomEntity.Type.RED.name); + } + + @Override + public boolean processInteract(@NotNull PlayerEntity player, Hand hand) { + ItemStack itemstack = player.getHeldItem(hand); + if (false && itemstack.getItem() == Items.SHEARS) { + this.world.addParticle(ParticleTypes.EXPLOSION, this.getPosX(), this.getPosYHeight(0.5D), this.getPosZ(), 0.0D, 0.0D, 0.0D); + if (!this.world.isRemote) { + this.remove(); + InfectedCowEntity cowentity = (InfectedCowEntity) EntityRegistry.INFECTED_COW_ENTITY.create(this.world); + cowentity.setLocationAndAngles(this.getPosX(), this.getPosY(), this.getPosZ(), this.rotationYaw, this.rotationPitch); + cowentity.setHealth(this.getHealth()); + cowentity.renderYawOffset = this.renderYawOffset; + if (this.hasCustomName()) { + cowentity.setCustomName(this.getCustomName()); + cowentity.setCustomNameVisible(this.isCustomNameVisible()); + } + + if (this.isNoDespawnRequired()) { + cowentity.enablePersistence(); + } + + cowentity.setInvulnerable(this.isInvulnerable()); + this.world.addEntity(cowentity); + + for(int k = 0; k < 5; ++k) { + this.world.addEntity(new ItemEntity(this.world, this.getPosX(), this.getPosYHeight(1.0D), this.getPosZ(), new ItemStack(this.getMooshroomType().renderState.getBlock()))); + } + + itemstack.damageItem(1, player, (p_213442_1_) -> p_213442_1_.sendBreakAnimation(hand)); + this.playSound(SoundEvents.ENTITY_MOOSHROOM_SHEAR, 1.0F, 1.0F); + } + + return true; + } else { + return super.processInteract(player, hand); + } + } + + @Override + public void writeAdditional(CompoundNBT compound) { + super.writeAdditional(compound); + compound.putString("Type", this.getMooshroomType().name); + if (this.hasStewEffect != null) { + compound.putByte("EffectId", (byte)Effect.getId(this.hasStewEffect)); + compound.putInt("EffectDuration", this.effectDuration); + } + + } + + @Override + public void readAdditional(CompoundNBT compound) { + super.readAdditional(compound); + this.setMooshroomType(InfectedMooshroomEntity.Type.getTypeByName(compound.getString("Type"))); + if (compound.contains("EffectId", 1)) { + this.hasStewEffect = Effect.get(compound.getByte("EffectId")); + } + + if (compound.contains("EffectDuration", 3)) { + this.effectDuration = compound.getInt("EffectDuration"); + } + + } + + private void setMooshroomType(@NotNull InfectedMooshroomEntity.Type typeIn) { + this.dataManager.set(MOOSHROOM_TYPE, typeIn.name); + } + + public InfectedMooshroomEntity.Type getMooshroomType() { + return InfectedMooshroomEntity.Type.getTypeByName(this.dataManager.get(MOOSHROOM_TYPE)); + } + + @Override + public boolean isShearable(@NotNull ItemStack item, net.minecraft.world.IWorldReader world, net.minecraft.util.math.BlockPos pos) { + return !this.isChild(); + } + + @NotNull + @Override + public java.util.List onSheared(@NotNull ItemStack item, net.minecraft.world.IWorld world, net.minecraft.util.math.BlockPos pos, int fortune) { + java.util.List ret = new java.util.ArrayList<>(); + this.world.addParticle(ParticleTypes.EXPLOSION, this.getPosX(), this.getPosYHeight(0.5D), this.getPosZ(), 0.0D, 0.0D, 0.0D); + if (!this.world.isRemote) { + this.remove(); + InfectedCowEntity cowentity = (InfectedCowEntity) EntityRegistry.INFECTED_COW_ENTITY.create(this.world); + assert cowentity != null; + cowentity.setLocationAndAngles(this.getPosX(), this.getPosY(), this.getPosZ(), this.rotationYaw, this.rotationPitch); + cowentity.setHealth(this.getHealth()); + cowentity.renderYawOffset = this.renderYawOffset; + if (this.hasCustomName()) { + cowentity.setCustomName(this.getCustomName()); + cowentity.setCustomNameVisible(this.isCustomNameVisible()); + } + this.world.addEntity(cowentity); + for(int i = 0; i < 5; ++i) { + ret.add(new ItemStack(this.getMooshroomType().renderState.getBlock())); + } + this.playSound(SoundEvents.ENTITY_MOOSHROOM_SHEAR, 1.0F, 1.0F); + } + return ret; + } + + public enum Type { + RED("red", Blocks.RED_MUSHROOM.getDefaultState()), + BROWN("brown", Blocks.BROWN_MUSHROOM.getDefaultState()); + + private final String name; + private final BlockState renderState; + + Type(String nameIn, BlockState renderStateIn) { + this.name = nameIn; + this.renderState = renderStateIn; + } + + @OnlyIn(Dist.CLIENT) + public BlockState getRenderState() { + return this.renderState; + } + + private static InfectedMooshroomEntity.Type getTypeByName(String nameIn) { + for(InfectedMooshroomEntity.Type mooshroomentity$type : values()) { + if (mooshroomentity$type.name.equals(nameIn)) { + return mooshroomentity$type; + } + } + + return RED; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/herobrine/mod/entities/InfectedPigEntity.java b/src/main/java/com/herobrine/mod/entities/InfectedPigEntity.java index 0bb46199..49724d03 100644 --- a/src/main/java/com/herobrine/mod/entities/InfectedPigEntity.java +++ b/src/main/java/com/herobrine/mod/entities/InfectedPigEntity.java @@ -1,22 +1,25 @@ package com.herobrine.mod.entities; import com.herobrine.mod.util.entities.EntityRegistry; -import com.herobrine.mod.util.entities.GenericSummoningRequiredEntityOnUpdateTick; +import com.herobrine.mod.util.entities.SummoningEntitySpawnSettings; import com.herobrine.mod.util.misc.Variables; import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.*; import net.minecraft.entity.ai.goal.*; import net.minecraft.entity.monster.MonsterEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.DamageSource; import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.IWorld; import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; +import javax.annotation.Nullable; + public class InfectedPigEntity extends MonsterEntity { public InfectedPigEntity(EntityType type, World worldIn) { super(type, worldIn); @@ -54,18 +57,17 @@ public boolean attackEntityFrom(@NotNull DamageSource source, float amount) { return false; return super.attackEntityFrom(source, amount); } - @Override - public void baseTick() { - super.baseTick(); + public ILivingEntityData onInitialSpawn(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) { Entity entity = this; { Variables.WorldVariables.get(world).syncData(world); java.util.HashMap $_dependencies = new java.util.HashMap<>(); $_dependencies.put("entity", entity); $_dependencies.put("world", world); - GenericSummoningRequiredEntityOnUpdateTick.executeProcedure($_dependencies); + SummoningEntitySpawnSettings.executeProcedure($_dependencies); } + return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); } @Override diff --git a/src/main/java/com/herobrine/mod/entities/InfectedSheepEntity.java b/src/main/java/com/herobrine/mod/entities/InfectedSheepEntity.java index a53ff525..f8c54839 100644 --- a/src/main/java/com/herobrine/mod/entities/InfectedSheepEntity.java +++ b/src/main/java/com/herobrine/mod/entities/InfectedSheepEntity.java @@ -2,7 +2,7 @@ import com.google.common.collect.Maps; import com.herobrine.mod.util.entities.EntityRegistry; -import com.herobrine.mod.util.entities.GenericSummoningRequiredEntityOnUpdateTick; +import com.herobrine.mod.util.entities.SummoningEntitySpawnSettings; import com.herobrine.mod.util.misc.Variables; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -10,17 +10,11 @@ import net.minecraft.entity.ai.goal.*; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.monster.MonsterEntity; -import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.SheepEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.DyeColor; -import net.minecraft.item.DyeItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.item.crafting.IRecipeType; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; @@ -140,19 +134,6 @@ public void livingTick() { super.livingTick(); } - @Override - public void baseTick() { - super.baseTick(); - Entity entity = this; - { - Variables.WorldVariables.get(world).syncData(world); - java.util.HashMap $_dependencies = new java.util.HashMap<>(); - $_dependencies.put("entity", entity); - $_dependencies.put("world", world); - GenericSummoningRequiredEntityOnUpdateTick.executeProcedure($_dependencies); - } - } - @Override protected void registerData() { super.registerData(); @@ -346,7 +327,14 @@ public void eatGrassBonus() { @Nullable @Override public ILivingEntityData onInitialSpawn(@NotNull IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) { - this.setFleeceColor(getRandomSheepColor(worldIn.getRandom())); + Entity entity = this; + { + Variables.WorldVariables.get(world).syncData(world); + java.util.HashMap $_dependencies = new java.util.HashMap<>(); + $_dependencies.put("entity", entity); + $_dependencies.put("world", world); + SummoningEntitySpawnSettings.executeProcedure($_dependencies); + } return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); } 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 c11682a2..cbc73dc5 100644 --- a/src/main/java/com/herobrine/mod/util/entities/EntityRegistry.java +++ b/src/main/java/com/herobrine/mod/util/entities/EntityRegistry.java @@ -22,6 +22,7 @@ public class EntityRegistry { public static EntityType INFECTED_CHICKEN_ENTITY = EntityType.Builder.create((EntityType type, World worldIn) -> new InfectedChickenEntity(worldIn), EntityClassification.MONSTER).size(0.4F, 0.7F).build("infected_chicken").setRegistryName("infected_chicken"); public static EntityType INFECTED_SHEEP_ENTITY = EntityType.Builder.create((EntityType type, World worldIn) -> new InfectedSheepEntity(worldIn), EntityClassification.MONSTER).size(0.9F, 1.3F).build("infected_sheep").setRegistryName("infected_sheep"); public static EntityType INFECTED_COW_ENTITY = EntityType.Builder.create((EntityType type, World worldIn) -> new InfectedCowEntity(worldIn), EntityClassification.MONSTER).size(0.9F, 1.4F).build("infected_cow").setRegistryName("infected_cow"); + public static EntityType INFECTED_MOOSHROOM_ENTITY = EntityType.Builder.create((EntityType type, World worldIn) -> new InfectedMooshroomEntity(worldIn), EntityClassification.MONSTER).size(0.9F, 1.4F).build("infected_mooshroom").setRegistryName("infected_mooshroom"); public static void registerEntitySpawnEggs(@NotNull final RegistryEvent.Register event) { event.getRegistry().registerAll( @@ -29,16 +30,19 @@ public static void registerEntitySpawnEggs(@NotNull final RegistryEvent.Register ItemList.infected_pig_spawn_egg = registerEntitySpawnEgg(INFECTED_PIG_ENTITY, 0xF0A5A2, 0xffffff, "infected_pig_spawn_egg"), ItemList.infected_chicken_spawn_egg = registerEntitySpawnEgg(INFECTED_CHICKEN_ENTITY, 0xA1A1A1, 0xffffff, "infected_chicken_spawn_egg"), ItemList.infected_sheep_spawn_egg = registerEntitySpawnEgg(INFECTED_SHEEP_ENTITY, 0xE7E7E7, 0xffffff, "infected_sheep_spawn_egg"), - ItemList.infected_cow_spawn_egg = registerEntitySpawnEgg(INFECTED_COW_ENTITY, 0x443626, 0xffffff, "infected_cow_spawn_egg") + ItemList.infected_cow_spawn_egg = registerEntitySpawnEgg(INFECTED_COW_ENTITY, 0x443626, 0xffffff, "infected_cow_spawn_egg"), + ItemList.infected_mooshroom_spawn_egg = registerEntitySpawnEgg(INFECTED_MOOSHROOM_ENTITY, 0xA00F10, 0xffffff, "infected_mooshroom_spawn_egg") ); } public static void registerEntityWorldSpawns() { registerEntityWorldSpawn(HEROBRINE_ENTITY, 3, 1, 1, Biomes.BEACH, Biomes.BAMBOO_JUNGLE_HILLS, Biomes.BAMBOO_JUNGLE, Biomes.BADLANDS_PLATEAU, Biomes.BADLANDS, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.DARK_FOREST_HILLS, Biomes.DESERT, Biomes.DESERT_HILLS, Biomes.DESERT_LAKES, Biomes.END_BARRENS, Biomes.END_HIGHLANDS, Biomes.END_MIDLANDS, Biomes.ERODED_BADLANDS, Biomes.FLOWER_FOREST, Biomes.FOREST, Biomes.FROZEN_RIVER, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_SPRUCE_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.GRAVELLY_MOUNTAINS, Biomes.ICE_SPIKES, Biomes.JUNGLE, Biomes.JUNGLE_EDGE, Biomes.JUNGLE_HILLS, Biomes.MODIFIED_BADLANDS_PLATEAU, Biomes.MODIFIED_GRAVELLY_MOUNTAINS, Biomes.MODIFIED_JUNGLE, Biomes.MODIFIED_JUNGLE_EDGE, Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, Biomes.MOUNTAINS, Biomes.MOUNTAIN_EDGE, Biomes.NETHER, Biomes.PLAINS, Biomes.RIVER, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.SHATTERED_SAVANNA, Biomes.SHATTERED_SAVANNA_PLATEAU, Biomes.SMALL_END_ISLANDS, Biomes.SNOWY_BEACH, Biomes.SNOWY_MOUNTAINS, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.SNOWY_TUNDRA, Biomes.STONE_SHORE, Biomes.SUNFLOWER_PLAINS, Biomes.SWAMP, Biomes.SWAMP_HILLS, Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.TAIGA_MOUNTAINS, Biomes.TALL_BIRCH_FOREST, Biomes.TALL_BIRCH_HILLS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.WOODED_HILLS, Biomes.WOODED_MOUNTAINS); + registerEntityWorldSpawn(HEROBRINE_ENTITY, 1,1, 1, Biomes.MUSHROOM_FIELD_SHORE, Biomes.MUSHROOM_FIELDS); registerEntityWorldSpawn(INFECTED_PIG_ENTITY, 7, 3, 6, Biomes.BAMBOO_JUNGLE_HILLS, Biomes.BAMBOO_JUNGLE, Biomes.BADLANDS_PLATEAU, Biomes.BADLANDS, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.DARK_FOREST_HILLS, Biomes.DESERT, Biomes.DESERT_HILLS, Biomes.DESERT_LAKES, Biomes.ERODED_BADLANDS, Biomes.FLOWER_FOREST, Biomes.FOREST, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_SPRUCE_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.GRAVELLY_MOUNTAINS, Biomes.JUNGLE, Biomes.JUNGLE_EDGE, Biomes.JUNGLE_HILLS, Biomes.MODIFIED_BADLANDS_PLATEAU, Biomes.MODIFIED_GRAVELLY_MOUNTAINS, Biomes.MODIFIED_JUNGLE, Biomes.MODIFIED_JUNGLE_EDGE, Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, Biomes.MOUNTAINS, Biomes.MOUNTAIN_EDGE, Biomes.PLAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.SHATTERED_SAVANNA, Biomes.SHATTERED_SAVANNA_PLATEAU, Biomes.SNOWY_BEACH, Biomes.SNOWY_MOUNTAINS, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.SNOWY_TUNDRA, Biomes.STONE_SHORE, Biomes.SUNFLOWER_PLAINS, Biomes.SWAMP, Biomes.SWAMP_HILLS, Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.TAIGA_MOUNTAINS, Biomes.TALL_BIRCH_FOREST, Biomes.TALL_BIRCH_HILLS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.WOODED_HILLS, Biomes.WOODED_MOUNTAINS); registerEntityWorldSpawn(INFECTED_CHICKEN_ENTITY, 7, 4, 8, Biomes.BAMBOO_JUNGLE_HILLS, Biomes.BAMBOO_JUNGLE, Biomes.BADLANDS_PLATEAU, Biomes.BADLANDS, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.DARK_FOREST_HILLS, Biomes.DESERT, Biomes.DESERT_HILLS, Biomes.DESERT_LAKES, Biomes.ERODED_BADLANDS, Biomes.FLOWER_FOREST, Biomes.FOREST, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_SPRUCE_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.GRAVELLY_MOUNTAINS, Biomes.JUNGLE, Biomes.JUNGLE_EDGE, Biomes.JUNGLE_HILLS, Biomes.MODIFIED_BADLANDS_PLATEAU, Biomes.MODIFIED_GRAVELLY_MOUNTAINS, Biomes.MODIFIED_JUNGLE, Biomes.MODIFIED_JUNGLE_EDGE, Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, Biomes.MOUNTAINS, Biomes.MOUNTAIN_EDGE, Biomes.PLAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.SHATTERED_SAVANNA, Biomes.SHATTERED_SAVANNA_PLATEAU, Biomes.SNOWY_BEACH, Biomes.SNOWY_MOUNTAINS, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.SNOWY_TUNDRA, Biomes.STONE_SHORE, Biomes.SUNFLOWER_PLAINS, Biomes.SWAMP, Biomes.SWAMP_HILLS, Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.TAIGA_MOUNTAINS, Biomes.TALL_BIRCH_FOREST, Biomes.TALL_BIRCH_HILLS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.WOODED_HILLS, Biomes.WOODED_MOUNTAINS); registerEntityWorldSpawn(INFECTED_SHEEP_ENTITY, 7, 3, 6, Biomes.BAMBOO_JUNGLE_HILLS, Biomes.BAMBOO_JUNGLE, Biomes.BADLANDS_PLATEAU, Biomes.BADLANDS, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.DARK_FOREST_HILLS, Biomes.DESERT, Biomes.DESERT_HILLS, Biomes.DESERT_LAKES, Biomes.ERODED_BADLANDS, Biomes.FLOWER_FOREST, Biomes.FOREST, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_SPRUCE_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.GRAVELLY_MOUNTAINS, Biomes.JUNGLE, Biomes.JUNGLE_EDGE, Biomes.JUNGLE_HILLS, Biomes.MODIFIED_BADLANDS_PLATEAU, Biomes.MODIFIED_GRAVELLY_MOUNTAINS, Biomes.MODIFIED_JUNGLE, Biomes.MODIFIED_JUNGLE_EDGE, Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, Biomes.MOUNTAINS, Biomes.MOUNTAIN_EDGE, Biomes.PLAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.SHATTERED_SAVANNA, Biomes.SHATTERED_SAVANNA_PLATEAU, Biomes.SNOWY_BEACH, Biomes.SNOWY_MOUNTAINS, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.SNOWY_TUNDRA, Biomes.STONE_SHORE, Biomes.SUNFLOWER_PLAINS, Biomes.SWAMP, Biomes.SWAMP_HILLS, Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.TAIGA_MOUNTAINS, Biomes.TALL_BIRCH_FOREST, Biomes.TALL_BIRCH_HILLS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.WOODED_HILLS, Biomes.WOODED_MOUNTAINS); registerEntityWorldSpawn(INFECTED_COW_ENTITY, 7, 2, 4, Biomes.BAMBOO_JUNGLE_HILLS, Biomes.BAMBOO_JUNGLE, Biomes.BADLANDS_PLATEAU, Biomes.BADLANDS, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.DARK_FOREST_HILLS, Biomes.DESERT, Biomes.DESERT_HILLS, Biomes.DESERT_LAKES, Biomes.ERODED_BADLANDS, Biomes.FLOWER_FOREST, Biomes.FOREST, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_SPRUCE_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.GRAVELLY_MOUNTAINS, Biomes.JUNGLE, Biomes.JUNGLE_EDGE, Biomes.JUNGLE_HILLS, Biomes.MODIFIED_BADLANDS_PLATEAU, Biomes.MODIFIED_GRAVELLY_MOUNTAINS, Biomes.MODIFIED_JUNGLE, Biomes.MODIFIED_JUNGLE_EDGE, Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, Biomes.MOUNTAINS, Biomes.MOUNTAIN_EDGE, Biomes.PLAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.SHATTERED_SAVANNA, Biomes.SHATTERED_SAVANNA_PLATEAU, Biomes.SNOWY_BEACH, Biomes.SNOWY_MOUNTAINS, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.SNOWY_TUNDRA, Biomes.STONE_SHORE, Biomes.SUNFLOWER_PLAINS, Biomes.SWAMP, Biomes.SWAMP_HILLS, Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.TAIGA_MOUNTAINS, Biomes.TALL_BIRCH_FOREST, Biomes.TALL_BIRCH_HILLS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.WOODED_HILLS, Biomes.WOODED_MOUNTAINS); + registerEntityWorldSpawn(INFECTED_MOOSHROOM_ENTITY, 1,1,1, Biomes.MUSHROOM_FIELDS, Biomes.MUSHROOM_FIELD_SHORE); } @NotNull diff --git a/src/main/java/com/herobrine/mod/util/entities/SummoningEntitySpawnSettings.java b/src/main/java/com/herobrine/mod/util/entities/SummoningEntitySpawnSettings.java new file mode 100644 index 00000000..4266896e --- /dev/null +++ b/src/main/java/com/herobrine/mod/util/entities/SummoningEntitySpawnSettings.java @@ -0,0 +1,22 @@ +package com.herobrine.mod.util.entities; + +import com.herobrine.mod.util.misc.ElementsHerobrine; +import com.herobrine.mod.util.misc.Variables; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; +import org.jetbrains.annotations.NotNull; + +@ElementsHerobrine.ModElement.Tag +public class SummoningEntitySpawnSettings extends ElementsHerobrine.ModElement { + public SummoningEntitySpawnSettings(ElementsHerobrine instance) { + super(instance, 9); + } + + public static void executeProcedure(@NotNull java.util.HashMap dependencies) { + World world = (World) dependencies.get("world"); + Entity entity = (Entity) dependencies.get("entity"); + if ((!(Variables.WorldVariables.get(world).Spawn))) { + entity.remove(); + } + } +} diff --git a/src/main/java/com/herobrine/mod/util/items/ItemList.java b/src/main/java/com/herobrine/mod/util/items/ItemList.java index 8d8fc886..568698a2 100644 --- a/src/main/java/com/herobrine/mod/util/items/ItemList.java +++ b/src/main/java/com/herobrine/mod/util/items/ItemList.java @@ -22,4 +22,5 @@ public class ItemList { public static Item infected_chicken_spawn_egg; public static Item infected_sheep_spawn_egg; public static Item infected_cow_spawn_egg; + public static Item infected_mooshroom_spawn_egg; } \ No newline at end of file