From 4582ef720d2b66f7b873dfc22a3e34e6d5c13271 Mon Sep 17 00:00:00 2001 From: Lizbeth Rika Date: Fri, 15 May 2015 18:11:57 +0100 Subject: [PATCH] Get the Incense Plate working and doing stuff. --- .../client/core/proxy/ClientProxy.java | 6 + .../botania/client/lib/LibRenderIDs.java | 1 + .../botania/client/lib/LibResources.java | 1 + .../client/model/ModelIncensePlate.java | 44 ++++++ .../render/block/RenderIncensePlate.java | 52 +++++++ .../render/tile/RenderTileIncensePlate.java | 98 ++++++++++++ .../common/block/BlockIncensePlate.java | 141 ++++++++++++++++++ .../botania/common/block/ModBlocks.java | 4 + .../common/block/tile/TileIncensePlate.java | 124 +++++++++++++++ .../vazkii/botania/common/brew/ModBrews.java | 2 +- .../common/core/BotaniaCreativeTab.java | 1 + .../botania/common/lib/LibBlockNames.java | 1 + .../resources/assets/botania/lang/en_US.lang | 1 + .../{incenseBurner.png => incensePlate.png} | Bin 14 files changed, 475 insertions(+), 1 deletion(-) create mode 100644 src/main/java/vazkii/botania/client/model/ModelIncensePlate.java create mode 100644 src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java create mode 100644 src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java create mode 100644 src/main/java/vazkii/botania/common/block/BlockIncensePlate.java create mode 100644 src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java rename src/main/resources/assets/botania/textures/model/{incenseBurner.png => incensePlate.png} (100%) 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 fdcd094aa..619a2dce0 100644 --- a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java @@ -58,6 +58,7 @@ import vazkii.botania.client.render.block.RenderCorporeaCrystalCube; import vazkii.botania.client.render.block.RenderCorporeaIndex; import vazkii.botania.client.render.block.RenderDoubleFlower; import vazkii.botania.client.render.block.RenderFloatingFlower; +import vazkii.botania.client.render.block.RenderIncensePlate; import vazkii.botania.client.render.block.RenderPool; import vazkii.botania.client.render.block.RenderPump; import vazkii.botania.client.render.block.RenderPylon; @@ -83,6 +84,7 @@ import vazkii.botania.client.render.tile.RenderTileCorporeaCrystalCube; import vazkii.botania.client.render.tile.RenderTileCorporeaIndex; import vazkii.botania.client.render.tile.RenderTileEnchanter; import vazkii.botania.client.render.tile.RenderTileFloatingFlower; +import vazkii.botania.client.render.tile.RenderTileIncensePlate; import vazkii.botania.client.render.tile.RenderTilePool; import vazkii.botania.client.render.tile.RenderTilePrism; import vazkii.botania.client.render.tile.RenderTilePump; @@ -102,6 +104,7 @@ import vazkii.botania.common.block.tile.TileBrewery; import vazkii.botania.common.block.tile.TileEnchanter; import vazkii.botania.common.block.tile.TileFloatingFlower; import vazkii.botania.common.block.tile.TileFloatingSpecialFlower; +import vazkii.botania.common.block.tile.TileIncensePlate; import vazkii.botania.common.block.tile.TilePylon; import vazkii.botania.common.block.tile.TileRuneAltar; import vazkii.botania.common.block.tile.TileSpawnerClaw; @@ -183,6 +186,7 @@ public class ClientProxy extends CommonProxy { LibRenderIDs.idPump = RenderingRegistry.getNextAvailableRenderId(); LibRenderIDs.idDoubleFlower = RenderingRegistry.getNextAvailableRenderId(); LibRenderIDs.idCorporeaCrystalCybe = RenderingRegistry.getNextAvailableRenderId(); + LibRenderIDs.idIncensePlate = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new RenderAltar()); RenderingRegistry.registerBlockHandler(new RenderSpecialFlower(LibRenderIDs.idSpecialFlower)); @@ -197,6 +201,7 @@ public class ClientProxy extends CommonProxy { RenderingRegistry.registerBlockHandler(new RenderPump()); RenderingRegistry.registerBlockHandler(new RenderDoubleFlower()); RenderingRegistry.registerBlockHandler(new RenderCorporeaCrystalCube()); + RenderingRegistry.registerBlockHandler(new RenderIncensePlate()); RenderTransparentItem renderTransparentItem = new RenderTransparentItem(); RenderFloatingFlowerItem renderFloatingFlower = new RenderFloatingFlowerItem(); @@ -232,6 +237,7 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaIndex.class, new RenderTileCorporeaIndex()); ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new RenderTilePump()); ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaCrystalCube.class, new RenderTileCorporeaCrystalCube()); + ClientRegistry.bindTileEntitySpecialRenderer(TileIncensePlate.class, new RenderTileIncensePlate()); 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 ca26ae459..5b39f0bce 100644 --- a/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java +++ b/src/main/java/vazkii/botania/client/lib/LibRenderIDs.java @@ -25,5 +25,6 @@ public final class LibRenderIDs { public static int idPump = -1; public static int idDoubleFlower = -1; public static int idCorporeaCrystalCybe = -1; + public static int idIncensePlate = -1; } diff --git a/src/main/java/vazkii/botania/client/lib/LibResources.java b/src/main/java/vazkii/botania/client/lib/LibResources.java index 35a7c5243..b201466e8 100644 --- a/src/main/java/vazkii/botania/client/lib/LibResources.java +++ b/src/main/java/vazkii/botania/client/lib/LibResources.java @@ -111,6 +111,7 @@ public final class LibResources { public static final String MODEL_MINI_ISLAND_SNOW = PREFIX_MODEL + "miniIslandSnow.png"; public static final String MODEL_PINK_WITHER = PREFIX_MODEL + "pinkWither.png"; 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 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/ModelIncensePlate.java b/src/main/java/vazkii/botania/client/model/ModelIncensePlate.java new file mode 100644 index 000000000..df45606a1 --- /dev/null +++ b/src/main/java/vazkii/botania/client/model/ModelIncensePlate.java @@ -0,0 +1,44 @@ +/** + * 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 @ [May 15, 2015, 4:17:37 PM (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 ModelIncensePlate extends ModelBase { + + ModelRenderer Plate; + ModelRenderer High; + + public ModelIncensePlate() { + textureWidth = 64; + textureHeight = 32; + + Plate = new ModelRenderer(this, 0, 0); + Plate.addBox(0F, 0F, 0F, 12, 1, 4); + Plate.setRotationPoint(-6F, 23F, -2F); + Plate.setTextureSize(64, 32); + Plate.mirror = true; + High = new ModelRenderer(this, 0, 6); + High.addBox(0F, 0F, 0F, 3, 1, 4); + High.setRotationPoint(-6F, 22F, -2F); + High.setTextureSize(64, 32); + High.mirror = true; + } + + public void render() { + float f5 = 1F / 16F; + Plate.render(f5); + High.render(f5); + } + +} diff --git a/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java b/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java new file mode 100644 index 000000000..dca7098c9 --- /dev/null +++ b/src/main/java/vazkii/botania/client/render/block/RenderIncensePlate.java @@ -0,0 +1,52 @@ +/** + * 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 @ [May 15, 2015, 5:59:56 PM (GMT)] + */ +package vazkii.botania.client.render.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import vazkii.botania.client.lib.LibRenderIDs; +import vazkii.botania.client.render.tile.RenderTilePool; +import vazkii.botania.common.block.tile.TileIncensePlate; +import vazkii.botania.common.block.tile.mana.TilePool; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +public class RenderIncensePlate implements ISimpleBlockRenderingHandler{ + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.1F, -0.5F); + GL11.glScalef(1.4F, 1.4F, 1.4F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileIncensePlate(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } + + @Override + public int getRenderId() { + return LibRenderIDs.idIncensePlate; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + +} diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java new file mode 100644 index 000000000..7cdaa83e8 --- /dev/null +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java @@ -0,0 +1,98 @@ +/** + * 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 @ [May 15, 2015, 4:27:27 PM (GMT)] + */ +package vazkii.botania.client.render.tile; + +import java.awt.Color; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import vazkii.botania.client.core.handler.ClientTickHandler; +import vazkii.botania.client.lib.LibRenderIDs; +import vazkii.botania.client.lib.LibResources; +import vazkii.botania.client.model.ModelIncensePlate; +import vazkii.botania.common.block.tile.TileIncensePlate; +import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +public class RenderTileIncensePlate extends TileEntitySpecialRenderer { + + private static final float[] ROTATIONS = new float[] { + 180F, 0F, 90F, 270F + }; + + ResourceLocation texture = new ResourceLocation(LibResources.MODEL_INCENSE_PLATE); + ModelIncensePlate model = new ModelIncensePlate(); + + @Override + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { + TileIncensePlate plate = (TileIncensePlate) tileentity; + + int meta = plate.getWorldObj() != null ? plate.getBlockMetadata() : 0; + + 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.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F); + model.render(); + GL11.glScalef(1F, -1F, -1F); + + ItemStack stack = plate.getStackInSlot(0); + if(stack != null) { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + float s = 0.4F; + GL11.glTranslatef(0.1F, -1.45F, 0F); + GL11.glScalef(s, s, s); + GL11.glRotatef(180F, 0F, 1F, 0F); + + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if(icon != null) { + Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass)); + GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glColor3f(1F, 1F, 1F); + } + renderPass++; + } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + GL11.glPopMatrix(); + } + GL11.glColor3f(1F, 1F, 1F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + +} diff --git a/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java b/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java new file mode 100644 index 000000000..006093ac0 --- /dev/null +++ b/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java @@ -0,0 +1,141 @@ +/** + * 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 @ [May 15, 2015, 4:07:09 PM (GMT)] + */ +package vazkii.botania.common.block; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.common.util.RotationHelper; +import vazkii.botania.api.brew.Brew; +import vazkii.botania.api.internal.VanillaPacketDispatcher; +import vazkii.botania.client.lib.LibRenderIDs; +import vazkii.botania.common.block.tile.TileIncensePlate; +import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.item.brew.ItemIncenseStick; +import vazkii.botania.common.lib.LibBlockNames; + +public class BlockIncensePlate extends BlockModContainer { + + private static final int[] META_ROTATIONS = new int[] { 2, 5, 3, 4 }; + + protected BlockIncensePlate() { + super(Material.wood); + setBlockName(LibBlockNames.INCENSE_PLATE); + setHardness(2.0F); + setStepSound(soundTypeWood); + setBlockBounds(true); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) { + TileIncensePlate plate = (TileIncensePlate) world.getTileEntity(x, y, z); + ItemStack stack = player.getCurrentEquippedItem(); + ItemStack plateStack = plate.getStackInSlot(0); + boolean did = false; + + if(world.isRemote) + return true; + + if(plateStack == null && plate.isItemValidForSlot(0, stack)) { + plate.setInventorySlotContents(0, stack.copy()); + stack.stackSize--; + did = true; + } else if(plateStack != null && !plate.burning) { + if(stack != null && stack.getItem() == Items.flint_and_steel) { + plate.burning = true; + Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(plateStack); + plate.timeLeft = brew.getPotionEffects(plateStack).get(0).getDuration() * ItemIncenseStick.TIME_MULTIPLIER; + stack.damageItem(1, player); + did = true; + } else { + ItemStack addStack = plateStack.copy(); + if(!player.inventory.addItemStackToInventory(addStack)) + player.dropPlayerItemWithRandomChoice(addStack, false); + plate.setInventorySlotContents(0, null); + + did = true; + } + } + + if(did) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(plate); + + return did; + } + + @Override + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { + int l = MathHelper.floor_double(p_149689_5_.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, META_ROTATIONS[l], 2); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) { + setBlockBounds(w.getBlockMetadata(x, y, z) < 4); + } + + public void setBlockBounds(boolean horiz) { + float f = 1F / 16F; + float w = 12 * f; + float l = 4 * f; + float xs = (1F - w) / 2; + float zs = (1F - l) / 2; + if(horiz) + setBlockBounds(xs, 0F, zs, 1F - xs, f, 1f - zs); + else setBlockBounds(zs, 0F, xs, 1F - zs, f, 1f - xs); + } + + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + return RotationHelper.rotateVanillaBlock(Blocks.furnace, worldObj, x, y, z, axis); + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + // NO-OP + } + + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return ModBlocks.livingwood.getIcon(0, 0); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return LibRenderIDs.idIncensePlate; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileIncensePlate(); + } + +} diff --git a/src/main/java/vazkii/botania/common/block/ModBlocks.java b/src/main/java/vazkii/botania/common/block/ModBlocks.java index 3d7d1d5a7..67cb4810e 100644 --- a/src/main/java/vazkii/botania/common/block/ModBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModBlocks.java @@ -119,6 +119,7 @@ import vazkii.botania.common.block.tile.TileFakeAir; import vazkii.botania.common.block.tile.TileFloatingFlower; import vazkii.botania.common.block.tile.TileFloatingSpecialFlower; import vazkii.botania.common.block.tile.TileForestEye; +import vazkii.botania.common.block.tile.TileIncensePlate; import vazkii.botania.common.block.tile.TileManaBeacon; import vazkii.botania.common.block.tile.TileManaFlame; import vazkii.botania.common.block.tile.TileOpenCrate; @@ -224,6 +225,7 @@ public final class ModBlocks { public static Block blazeBlock; public static Block corporeaInterceptor; public static Block corporeaCrystalCube; + public static Block incensePlate; public static void init() { flower = new BlockModFlower(); @@ -294,6 +296,7 @@ public final class ModBlocks { blazeBlock = new BlockBlaze(); corporeaInterceptor = new BlockCorporeaInterceptor(); corporeaCrystalCube = new BlockCorporeaCrystalCube(); + incensePlate = new BlockIncensePlate(); ModFluffBlocks.init(); @@ -381,6 +384,7 @@ public final class ModBlocks { registerTile(TileFakeAir.class, LibBlockNames.FAKE_AIR); registerTile(TileCorporeaInterceptor.class, LibBlockNames.CORPOREA_INTERCEPTOR); registerTile(TileCorporeaCrystalCube.class, LibBlockNames.CORPOREA_CRYSTAL_CUBE); + registerTile(TileIncensePlate.class, LibBlockNames.INCENSE_PLATE); 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/TileIncensePlate.java b/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java new file mode 100644 index 000000000..57ec158ae --- /dev/null +++ b/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java @@ -0,0 +1,124 @@ +/** + * 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 @ [May 15, 2015, 4:09:07 PM (GMT)] + */ +package vazkii.botania.common.block.tile; + +import java.awt.Color; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.api.brew.Brew; +import vazkii.botania.api.internal.VanillaPacketDispatcher; +import vazkii.botania.common.Botania; +import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.item.brew.ItemIncenseStick; +import vazkii.botania.common.lib.LibBlockNames; + +public class TileIncensePlate extends TileSimpleInventory implements ISidedInventory { + + private static final String TAG_TIME_LEFT = "timeLeft"; + private static final String TAG_BURNING = "burning"; + private static final int RANGE = 24; + + public int timeLeft = 0; + public boolean burning = false; + + @Override + public void updateEntity() { + ItemStack stack = getStackInSlot(0); + if(stack != null && burning) { + Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); + PotionEffect effect = brew.getPotionEffects(stack).get(0); + if(timeLeft > 0) { + timeLeft--; + if(!worldObj.isRemote) { + List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord + 0.5 - RANGE, yCoord + 0.5 - RANGE, zCoord + 0.5 - RANGE, xCoord + 0.5 + RANGE, yCoord + 0.5 + RANGE, zCoord + 0.5 + RANGE)); + for(EntityPlayer player : players) { + PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]); + boolean nightVision = effect.getPotionID() == Potion.nightVision.id; + if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { + PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true); + player.addPotionEffect(applyEffect); + } + } + + if(worldObj.rand.nextInt(20) == 0) + worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.1, zCoord + 0.5, "fire.fire", 0.1F, 1F); + } else { + double x = xCoord + 0.5; + double y = yCoord + 0.5; + double z = zCoord + 0.5; + Color color = new Color(brew.getColor(stack)); + float r = color.getRed() / 255F; + float g = color.getGreen() / 255F; + float b = color.getBlue() / 255F; + Botania.proxy.wispFX(worldObj, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, r, g, b, 0.05F + (float) Math.random() * 0.02F, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.005F, 0.005F - (float) Math.random() * 0.01F); + Botania.proxy.wispFX(worldObj, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, 0.2F, 0.2F, 0.2F, 0.05F + (float) Math.random() * 0.02F, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.001F, 0.005F - (float) Math.random() * 0.01F); + } + } else { + setInventorySlotContents(0, null); + burning = false; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + } else timeLeft = 0; + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public String getInventoryName() { + return LibBlockNames.INCENSE_PLATE; + } + + @Override + public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.writeCustomNBT(par1nbtTagCompound); + par1nbtTagCompound.setInteger(TAG_TIME_LEFT, timeLeft); + par1nbtTagCompound.setBoolean(TAG_BURNING, burning); + } + + @Override + public void readCustomNBT(NBTTagCompound par1nbtTagCompound) { + super.readCustomNBT(par1nbtTagCompound); + timeLeft = par1nbtTagCompound.getInteger(TAG_TIME_LEFT); + burning = par1nbtTagCompound.getBoolean(TAG_BURNING); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack != null && itemstack.getItem() == ModItems.incenseStick && ((ItemIncenseStick) ModItems.incenseStick).getBrew(itemstack) != BotaniaAPI.fallbackBrew; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] { 0 }; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side) { + return isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + +} diff --git a/src/main/java/vazkii/botania/common/brew/ModBrews.java b/src/main/java/vazkii/botania/common/brew/ModBrews.java index deecb6b19..e7d7f38e5 100644 --- a/src/main/java/vazkii/botania/common/brew/ModBrews.java +++ b/src/main/java/vazkii/botania/common/brew/ModBrews.java @@ -53,7 +53,7 @@ public class ModBrews { waterBreathing = new BrewMod(LibBrewNames.WATER_BREATHING, 0x84A7CF, 4000, new PotionEffect(Potion.waterBreathing.id, 9600, 0)); invisibility = new BrewMod(LibBrewNames.INVISIBILITY, 0xAEAEAE, 8000, new PotionEffect(Potion.invisibility.id, 9600, 0)); nightVision = new BrewMod(LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new PotionEffect(Potion.nightVision.id, 9600, 0)); - absorption = new BrewMod(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffect(Potion.field_76444_x.id, 1800, 3)).setNotBloodPendantInfusable(); + absorption = new BrewMod(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffect(Potion.field_76444_x.id, 1800, 3)).setNotBloodPendantInfusable().setNotIncenseInfusable(); overload = new BrewMod(LibBrewNames.OVERLOAD, 0x232323, 12000, new PotionEffect(Potion.damageBoost.id, 1800, 3), new PotionEffect(Potion.moveSpeed.id, 1800, 2), new PotionEffect(Potion.weakness.id, 2400, 2), new PotionEffect(Potion.hunger.id, 200, 2)); soulCross = new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffect(ModPotions.soulCross.id, 1800, 0)); diff --git a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java index 67972994c..9c8a9bb49 100644 --- a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java +++ b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java @@ -120,6 +120,7 @@ public final class BotaniaCreativeTab extends CreativeTabs { addItem(ModItems.vial); addItem(ModItems.brewVial); addItem(ModItems.brewFlask); + addBlock(ModBlocks.incensePlate); addItem(ModItems.incenseStick); addItem(ModItems.bloodPendant); addBlock(ModBlocks.pylon); diff --git a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java index a8e390217..5c46e1322 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java @@ -83,6 +83,7 @@ public final class LibBlockNames { public static final String BLAZE_BLOCK = "blazeBlock"; public static final String CORPOREA_INTERCEPTOR = "corporeaInterceptor"; public static final String CORPOREA_CRYSTAL_CUBE = "corporeaCrystalCube"; + public static final String INCENSE_PLATE = "incensePlate"; 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 bd9a6d6f3..eec008be7 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -916,6 +916,7 @@ tile.botania:stone11Slab.name=Granite Brick Slab tile.botania:blazeBlock.name=Blaze Lamp tile.botania:corporeaInterceptor.name=Corporea Interceptor tile.botania:corporeaCrystalCube.name=Corporea Crystal Cube +tile.botania:incensePlate.name=Incense Plate # FLOWER NAMES tile.botania:flower..name=Botania Flower diff --git a/src/main/resources/assets/botania/textures/model/incenseBurner.png b/src/main/resources/assets/botania/textures/model/incensePlate.png similarity index 100% rename from src/main/resources/assets/botania/textures/model/incenseBurner.png rename to src/main/resources/assets/botania/textures/model/incensePlate.png