From 8910b91f020584d009c6997331b35580074ce1ff Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 7 Aug 2016 13:09:44 +0200 Subject: [PATCH] Added a config option to make worms die after a certain amout of time --- .../mod/config/values/ConfigIntValues.java | 1 + .../actuallyadditions/mod/entity/EntityWorm.java | 10 ++++++++-- .../actuallyadditions/mod/entity/RenderWorm.java | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java index e561e36c6..26fb67f1c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java @@ -22,6 +22,7 @@ public enum ConfigIntValues{ COFFEE_AMOUNT("Coffee: Amount", ConfigCategories.WORLD_GEN, 6, 1, 50, "The Amount of Coffee generating"), BLACK_LOTUS_AMOUNT("Black Lotus: Amount", ConfigCategories.WORLD_GEN, 14, 1, 50, "The Amount of Black Lotus generating"), LUSH_CAVE_CHANCE("Lush Caves: Chance", ConfigCategories.WORLD_GEN, 20, 1, 100, "The chance for lush caves to generate. The lower the number, the likelier."), + WORMS_DIE_TIME("Worm Death Time", ConfigCategories.OTHER, 0, 0, 10000000, "The amount of ticks it takes for a worm to die. Set it to zero to make worms not die at all."), TILE_ENTITY_UPDATE_INTERVAL("Tile Entities: Update Interval", ConfigCategories.OTHER, 5, 1, 100, "The amount of ticks waited before a TileEntity sends an additional Update to the Client"), CTRL_INFO_NBT_CHAR_LIMIT("Advanced Info NBT Character Limit", ConfigCategories.OTHER, 1000, 0, 100000000, "The maximum amount of characters that is displayed by the NBT view of the CTRL Advanced Info. Set to a zero to have no limit"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java index 046eacf14..7d46a259d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.entity; +import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; @@ -50,9 +51,9 @@ public class EntityWorm extends Entity{ @Override public void onEntityUpdate(){ - this.timer++; - if(!this.worldObj.isRemote){ + this.timer++; + if(this.timer%50 == 0){ for(int x = -1; x <= 1; x++){ for(int z = -1; z <= 1; z++){ @@ -98,6 +99,11 @@ public class EntityWorm extends Entity{ } } } + + int dieTime = ConfigIntValues.WORMS_DIE_TIME.getValue(); + if(dieTime > 0 && this.timer >= dieTime){ + this.setDead(); + } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java index 00ee0c184..4b72561c1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java @@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.entity; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; @@ -47,7 +48,8 @@ public class RenderWorm extends Render{ public void doRender(EntityWorm entity, double x, double y, double z, float entityYaw, float partialTicks){ GlStateManager.pushMatrix(); GlStateManager.translate(x, y+0.7F, z); - GlStateManager.rotate((float)(((entity.timer)%360)), 0, 1, 0); + double boop = Minecraft.getSystemTime()/70D; + GlStateManager.rotate((float)((boop%360)), 0, 1, 0); GlStateManager.translate(0, 0, 0.4); AssetUtil.renderItemInWorld(STACK); GlStateManager.popMatrix();