diff --git a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java index 9d5fd44dd..0d7ef099b 100644 --- a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java @@ -88,6 +88,7 @@ import vazkii.botania.client.render.item.RenderTransparentItem; import vazkii.botania.client.render.tile.RenderTileAlfPortal; import vazkii.botania.client.render.tile.RenderTileAltar; import vazkii.botania.client.render.tile.RenderTileBrewery; +import vazkii.botania.client.render.tile.RenderTileCocoon; import vazkii.botania.client.render.tile.RenderTileCorporeaCrystalCube; import vazkii.botania.client.render.tile.RenderTileCorporeaIndex; import vazkii.botania.client.render.tile.RenderTileEnchanter; @@ -111,6 +112,7 @@ import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileAlfPortal; import vazkii.botania.common.block.tile.TileAltar; import vazkii.botania.common.block.tile.TileBrewery; +import vazkii.botania.common.block.tile.TileCocoon; import vazkii.botania.common.block.tile.TileEnchanter; import vazkii.botania.common.block.tile.TileFloatingFlower; import vazkii.botania.common.block.tile.TileFloatingSpecialFlower; @@ -225,6 +227,7 @@ public class ClientProxy extends CommonProxy { LibRenderIDs.idCorporeaCrystalCybe = RenderingRegistry.getNextAvailableRenderId(); LibRenderIDs.idIncensePlate = RenderingRegistry.getNextAvailableRenderId(); LibRenderIDs.idHourglass = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idCocoon = RenderingRegistry.getNextAvailableRenderId(); RenderSpecialFlower specialFlowerRender = new RenderSpecialFlower(LibRenderIDs.idSpecialFlower); RenderingRegistry.registerBlockHandler(new RenderAltar()); @@ -283,6 +286,7 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileIncensePlate.class, new RenderTileIncensePlate()); ClientRegistry.bindTileEntitySpecialRenderer(TileHourglass.class, new RenderTileHourglass()); ClientRegistry.bindTileEntitySpecialRenderer(TileSparkChanger.class, new RenderTileSparkChanger()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCocoon.class, new RenderTileCocoon()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkull.class, new RenderTileSkullOverride()); diff --git a/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java b/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java index 4d50ce560..5f215784f 100644 --- a/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java +++ b/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java @@ -27,5 +27,6 @@ public final class LibRenderIDs { public static int idCorporeaCrystalCybe = -1; public static int idIncensePlate = -1; public static int idHourglass = -1; + public static int idCocoon = -1; } diff --git a/src/main/java/vazkii/botania/client/lib/LibResources.java b/src/main/java/vazkii/botania/client/lib/LibResources.java index 6781bc598..3bb71cb8f 100644 --- a/src/main/java/vazkii/botania/client/lib/LibResources.java +++ b/src/main/java/vazkii/botania/client/lib/LibResources.java @@ -104,6 +104,7 @@ public final class LibResources { public static final String MODEL_CRYSTAL_CUBE = PREFIX_MODEL + "crystalCube.png"; public static final String MODEL_INCENSE_PLATE = PREFIX_MODEL + "incensePlate.png"; public static final String MODEL_HOURGLASS = PREFIX_MODEL + "hourglass.png"; + public static final String MODEL_COCOON = PREFIX_MODEL + "cocoon.png"; public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png"; public static final String MISC_WISP_LARGE = PREFIX_MISC + "wispLarge.png"; diff --git a/src/main/java/vazkii/botania/client/model/ModelCocoon.java b/src/main/java/vazkii/botania/client/model/ModelCocoon.java new file mode 100644 index 000000000..122e15d3a --- /dev/null +++ b/src/main/java/vazkii/botania/client/model/ModelCocoon.java @@ -0,0 +1,33 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + * File Created @ [? (GMT)] + */ +package vazkii.botania.client.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelCocoon extends ModelBase { + + public ModelRenderer shape; + + public ModelCocoon() { + textureWidth = 48; + textureHeight = 32; + shape = new ModelRenderer(this, 0, 0); + shape.setRotationPoint(0.0F, 22.0F, 0.0F); + shape.addBox(-5.0F, -8.0F, -7.0F, 10, 10, 14, 0.0F); + } + + public void render() { + shape.render(1F / 16F); + } + +} diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java new file mode 100644 index 000000000..15cc160a8 --- /dev/null +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java @@ -0,0 +1,57 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + * File Created @ [Jul 8, 2015, 4:44:23 PM (GMT)] + */ +package vazkii.botania.client.render.tile; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import vazkii.botania.client.lib.LibResources; +import vazkii.botania.client.model.ModelCocoon; +import vazkii.botania.common.block.tile.TileCocoon; + +public class RenderTileCocoon extends TileEntitySpecialRenderer { + + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_COCOON); + ModelCocoon model = new ModelCocoon(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + TileCocoon cocoon = (TileCocoon) tileentity; + + float rot = 0F; + float modval = 60F - (float) cocoon.timePassed / (float) TileCocoon.TOTAL_TIME * 30F; + if(cocoon.timePassed % modval < 10) { + float mod = (cocoon.timePassed + f) % (float) modval; + float v = (float) mod / 5 * (float) Math.PI * 2; + rot = (float) Math.sin(v) * (float) Math.log(cocoon.timePassed + f); + } + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(d0, d1, d2); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0.5F, -0.5F - 3F / 16F, -0.5F + 1F / 16F); + GL11.glRotatef(rot, 0F, 1F, 0F); + model.render(); + GL11.glColor3f(1F, 1F, 1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/vazkii/botania/common/block/BlockCocoon.java b/src/main/java/vazkii/botania/common/block/BlockCocoon.java new file mode 100644 index 000000000..432c0b8bd --- /dev/null +++ b/src/main/java/vazkii/botania/common/block/BlockCocoon.java @@ -0,0 +1,80 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + * File Created @ [Jul 8, 2015, 4:29:01 PM (GMT)] + */ +package vazkii.botania.common.block; + +import java.util.ArrayList; +import java.util.Random; + +import vazkii.botania.client.lib.LibRenderIDs; +import vazkii.botania.common.block.tile.TileCocoon; +import vazkii.botania.common.lib.LibBlockNames; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockCocoon extends BlockModContainer { + + protected BlockCocoon() { + super(Material.cloth); + setHardness(3.0F); + setResistance(50.0F); + setStepSound(soundTypeCloth); + setBlockName(LibBlockNames.COCOON); + float f = 3F / 16F; + float f1 = 14F / 16F; + setBlockBounds(f, 0F, f, 1F - f, f1, 1F - f); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return Blocks.web.getBlockTextureFromSide(0); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idCocoon; + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileCocoon(); + } + +} diff --git a/src/main/java/vazkii/botania/common/block/ModBlocks.java b/src/main/java/vazkii/botania/common/block/ModBlocks.java index 613dde7a5..b0b7e8be5 100644 --- a/src/main/java/vazkii/botania/common/block/ModBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModBlocks.java @@ -112,6 +112,7 @@ import vazkii.botania.common.block.tile.TileAlfPortal; import vazkii.botania.common.block.tile.TileAltar; import vazkii.botania.common.block.tile.TileBifrost; import vazkii.botania.common.block.tile.TileBrewery; +import vazkii.botania.common.block.tile.TileCocoon; import vazkii.botania.common.block.tile.TileCraftCrate; import vazkii.botania.common.block.tile.TileEnchanter; import vazkii.botania.common.block.tile.TileEnderEye; @@ -233,6 +234,7 @@ public final class ModBlocks { public static Block sparkChanger; public static Block root; public static Block felPumpkin; + public static Block cocoon; public static void init() { flower = new BlockModFlower(); @@ -309,6 +311,7 @@ public final class ModBlocks { sparkChanger = new BlockSparkChanger(); root = new BlockRoot(); felPumpkin = new BlockFelPumpkin(); + cocoon = new BlockCocoon(); ModFluffBlocks.init(); @@ -399,6 +402,7 @@ public final class ModBlocks { registerTile(TileIncensePlate.class, LibBlockNames.INCENSE_PLATE); registerTile(TileHourglass.class, LibBlockNames.HOURGLASS); registerTile(TileSparkChanger.class, LibBlockNames.SPARK_CHANGER); + registerTile(TileCocoon.class, LibBlockNames.COCOON); BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class); BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java b/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java new file mode 100644 index 000000000..41b1b3669 --- /dev/null +++ b/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java @@ -0,0 +1,101 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + * File Created @ [Jul 8, 2015, 4:32:34 PM (GMT)] + */ +package vazkii.botania.common.block.tile; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.nbt.NBTTagCompound; + +public class TileCocoon extends TileMod { + + private static final String TAG_TIME_PASSED = "timePassed"; + + public static final int TOTAL_TIME = 2400; + + public int timePassed; + + @Override + public void updateEntity() { + timePassed++; + if(timePassed >= TOTAL_TIME) + hatch(); + } + + public void hatch() { + if(!worldObj.isRemote) { + worldObj.playAuxSFX(2001, xCoord, yCoord, zCoord, Block.getIdFromBlock(getBlockType())); + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + + EntityAnimal entity = null; + + float specialChance = 0.05F; + if(Math.random() < specialChance) { + int entityType = worldObj.rand.nextInt(3); + switch(entityType) { + case 0: + entity = new EntityHorse(worldObj); + break; + case 1: + entity = new EntityWolf(worldObj); + break; + case 2: + entity = new EntityOcelot(worldObj); + break; + } + } else { + int entityType = worldObj.rand.nextInt(4); + switch(entityType) { + case 0: + entity = new EntitySheep(worldObj); + break; + case 1: + if(Math.random() < 0.01) + entity = new EntityMooshroom(worldObj); + else entity = new EntityCow(worldObj); + break; + case 2: + entity = new EntityPig(worldObj); + break; + case 3: + entity = new EntityChicken(worldObj); + break; + } + } + + if(entity != null) { + entity.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + entity.setGrowingAge(-24000); + worldObj.spawnEntityInWorld(entity); + entity.spawnExplosionParticle(); + } + } + } + + @Override + public void writeCustomNBT(NBTTagCompound cmp) { + cmp.setInteger(TAG_TIME_PASSED, timePassed); + } + + @Override + public void readCustomNBT(NBTTagCompound cmp) { + timePassed = cmp.getInteger(TAG_TIME_PASSED); + } + +} diff --git a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java index 331f19594..2043c2e0f 100644 --- a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java +++ b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java @@ -105,6 +105,7 @@ public final class BotaniaCreativeTab extends CreativeTabs { addItem(ModItems.craftingHalo); addItem(ModItems.spawnerMover); addBlock(ModBlocks.spawnerClaw); + addBlock(ModBlocks.cocoon); addItem(ModItems.blackHoleTalisman); if(Botania.gardenOfGlassLoaded) diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 1e7769919..133024621 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -775,7 +775,7 @@ public final class LexiconData { spawnerMover = new ALexiconEntry(LibLexicon.ENDER_SPAWNER_MOVER, categoryEnder); spawnerMover.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeSpawnerMover)); - keepIvy = new ALexiconEntry(LibLexicon.ENDER_KEEP_IVY, categoryEnder); + keepIvy = new ALexiconEntry(LibLexicon.ENDER_KEEP_IVY, categoryEnder); keepIvy.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeKeepIvy)); blackHoleTalisman = new ALexiconEntry(LibLexicon.ENDER_BLACK_HOLE_TALISMAN, categoryEnder); diff --git a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java index 3594b2403..4714fbbfc 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java @@ -89,6 +89,7 @@ public final class LibBlockNames { public static final String SPARK_CHANGER = "sparkChanger"; public static final String ROOT = "root"; public static final String FEL_PUMPKIN = "felPumpkin"; + public static final String COCOON = "cocoon"; public static final String SUBTILE_PUREDAISY = "puredaisy"; public static final String SUBTILE_MANASTAR = "manastar"; diff --git a/src/main/resources/assets/botania/lang/en_US.lang b/src/main/resources/assets/botania/lang/en_US.lang index 1c7e5f8e6..eeb0bb021 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -995,6 +995,7 @@ tile.botania:ghostRail.name=Spectral Rail tile.botania:sparkChanger.name=Spark Tinkerer tile.botania:root.name=Living Root tile.botania:felPumpkin.name=Fel Pumpkin +tile.botania:cocoon.name=Cocoon of Caprice # FLOWER NAMES tile.botania:flower..name=Botania Flower diff --git a/src/main/resources/assets/botania/textures/model/capriceCocoon.java b/src/main/resources/assets/botania/textures/model/capriceCocoon.java deleted file mode 100644 index 5a5f0e4da..000000000 --- a/src/main/resources/assets/botania/textures/model/capriceCocoon.java +++ /dev/null @@ -1,35 +0,0 @@ -package model; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; - -/** - * capriceCocoon - wiiv - * Created using Tabula 4.1.1 - */ -public class capriceCocoon extends ModelBase { - public ModelRenderer shape1; - - public capriceCocoon() { - this.textureWidth = 48; - this.textureHeight = 32; - this.shape1 = new ModelRenderer(this, 0, 0); - this.shape1.setRotationPoint(0.0F, 22.0F, 0.0F); - this.shape1.addBox(-5.0F, -8.0F, -7.0F, 10, 10, 14, 0.0F); - } - - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - this.shape1.render(f5); - } - - /** - * This is a helper function from Tabula to set the rotation of model parts - */ - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } -} diff --git a/src/main/resources/assets/botania/textures/model/capriceCocoon.png b/src/main/resources/assets/botania/textures/model/cocoon.png similarity index 100% rename from src/main/resources/assets/botania/textures/model/capriceCocoon.png rename to src/main/resources/assets/botania/textures/model/cocoon.png