From bd227a4867cd970dafab01e6815b864af66f8c14 Mon Sep 17 00:00:00 2001 From: Lizbeth Rika Date: Sat, 28 Feb 2015 23:44:48 +0000 Subject: [PATCH] Sleevable spreaders! --- .../render/tile/RenderTileSpreader.java | 35 +++++++++++++++++-- .../common/block/mana/BlockSpreader.java | 27 ++++++++++---- .../common/block/tile/mana/TileSpreader.java | 7 +++- .../botania/common/lexicon/LexiconData.java | 2 +- .../resources/assets/botania/lang/en_US.lang | 1 + 5 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java index 25facd987..834da913b 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java @@ -13,9 +13,12 @@ package vazkii.botania.client.render.tile; import java.awt.Color; import java.util.Random; +import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; @@ -39,7 +42,7 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer { private static final ModelSpreader model = new ModelSpreader(); @Override - public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { + public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) { TileSpreader spreader = (TileSpreader) tileentity; GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); @@ -55,7 +58,7 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer { Minecraft.getMinecraft().renderEngine.bindTexture(spreader.isRedstone() ? textureRs : spreader.isDreamwood() ? textureDw : texture); GL11.glScalef(1F, -1F, -1F); - double time = ClientTickHandler.ticksInGame + f; + double time = ClientTickHandler.ticksInGame + ticks; if(spreader.isULTRA_SPREADER()) { Color color = Color.getHSBColor((float) ((time * 5 + new Random(spreader.xCoord ^ spreader.yCoord ^ spreader.zCoord).nextInt(10000)) % 360) / 360F, 0.4F, 0.9F); @@ -82,6 +85,34 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer { RenderLens.render(stack, lens.getLensColor(stack)); GL11.glPopMatrix(); } + + if(spreader.paddingColor != -1) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + + Block block = Blocks.carpet; + int color = spreader.paddingColor; + RenderBlocks render = RenderBlocks.getInstance(); + float f = 1F / 16F; + GL11.glTranslatef(0F, -f, 0F); + render.renderBlockAsItem(block, color, 1F); + GL11.glTranslatef(0F, -f * 15, 0F); + render.renderBlockAsItem(block, color, 1F); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glRotatef(90F, 0F, 1F, 0F); + + GL11.glPushMatrix(); + GL11.glScalef(f * 14F, 1F, 1F); + render.renderBlockAsItem(block, color, 1F); + GL11.glPopMatrix(); + + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0F, 0F, -f / 2); + GL11.glScalef(f * 14F, 1F, f * 15F); + render.renderBlockAsItem(block, color, 1F); + GL11.glTranslatef(0F, f * 15F, 0F); + render.renderBlockAsItem(block, color, 1F); + } + GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java b/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java index f221d303f..a26864022 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java @@ -23,6 +23,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -144,6 +145,7 @@ public class BlockSpreader extends BlockModContainer implements IWandable, IWand ItemStack lens = spreader.getStackInSlot(0); ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem(); boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens; + boolean wool = heldItem != null && heldItem.getItem() == Item.getItemFromBlock(Blocks.wool); if(heldItem != null) if(heldItem.getItem() == ModItems.twigWand) @@ -153,7 +155,7 @@ public class BlockSpreader extends BlockModContainer implements IWandable, IWand par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); spreader.setInventorySlotContents(0, heldItem.copy()); spreader.markDirty(); - } else if(lens != null) { + } else if(lens != null && !wool) { ItemStack add = lens.copy(); if(!par5EntityPlayer.inventory.addItemStackToInventory(add)) par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false); @@ -161,22 +163,35 @@ public class BlockSpreader extends BlockModContainer implements IWandable, IWand spreader.markDirty(); } + if(wool && spreader.paddingColor == -1) { + spreader.paddingColor = heldItem.getItemDamage(); + heldItem.stackSize--; + if(heldItem.stackSize == 0) + par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null); + } else if(heldItem == null && spreader.paddingColor != -1 && lens == null) { + ItemStack pad = new ItemStack(Blocks.wool, 1, spreader.paddingColor); + if(!par5EntityPlayer.inventory.addItemStackToInventory(pad)) + par5EntityPlayer.dropPlayerItemWithRandomChoice(pad, false); + spreader.paddingColor = -1; + spreader.markDirty(); + } + return true; } @Override public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { TileEntity tile = par1World.getTileEntity(par2, par3, par4); - if(!(tile instanceof TileSimpleInventory)) + if(!(tile instanceof TileSpreader)) return; - TileSimpleInventory inv = (TileSimpleInventory) tile; + TileSpreader inv = (TileSpreader) tile; if (inv != null) { - for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { - ItemStack itemstack = inv.getStackInSlot(j1); + for (int j1 = 0; j1 < inv.getSizeInventory() + 1; ++j1) { + ItemStack itemstack = j1 >= inv.getSizeInventory() ? new ItemStack(Blocks.wool, 1, inv.paddingColor) : inv.getStackInSlot(j1); - if (itemstack != null) { + if (itemstack != null && itemstack.getItemDamage() == -1) { float f = random.nextFloat() * 0.8F + 0.1F; float f1 = random.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java index 237ca2c6f..4db94962e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java @@ -65,6 +65,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, private static final String TAG_REQUEST_UPDATE = "requestUpdate"; private static final String TAG_ROTATION_X = "rotationX"; private static final String TAG_ROTATION_Y = "rotationY"; + private static final String TAG_PADDING_COLOR = "paddingColor"; private static final String TAG_FORCE_CLIENT_BINDING_X = "forceClientBindingX"; private static final String TAG_FORCE_CLIENT_BINDING_Y = "forceClientBindingY"; @@ -103,6 +104,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, int mana; int knownMana = -1; public float rotationX, rotationY; + public int paddingColor = -1; boolean requestsClientUpdate = false; boolean hasReceivedInitialPacket = false; @@ -199,6 +201,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, cmp.setFloat(TAG_ROTATION_X, rotationX); cmp.setFloat(TAG_ROTATION_Y, rotationY); cmp.setBoolean(TAG_REQUEST_UPDATE, requestsClientUpdate); + cmp.setInteger(TAG_PADDING_COLOR, paddingColor); cmp.setString(TAG_INPUT_KEY, inputKey); cmp.setString(TAG_OUTPUT_KEY, outputKey); @@ -241,6 +244,8 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, if(cmp.hasKey(TAG_KNOWN_MANA)) knownMana = cmp.getInteger(TAG_KNOWN_MANA); + if(cmp.hasKey(TAG_PADDING_COLOR)) + paddingColor = cmp.getInteger(TAG_PADDING_COLOR); if(requestsClientUpdate && worldObj != null) { int x = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_X); @@ -331,7 +336,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, mana -= burst.getStartingMana(); worldObj.spawnEntityInWorld(burst); if(!ConfigHandler.silentSpreaders) - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:spreaderFire", 0.2F, 0.7F + 0.3F * (float) Math.random()); + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:spreaderFire", 0.05F * (paddingColor != -1 ? 0.2F : 1F), 0.7F + 0.3F * (float) Math.random()); } canShootBurst = false; diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 6b00d93a7..2c45af41d 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -297,7 +297,7 @@ public final class LexiconData { manaIntro.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")); spreader = new BLexiconEntry(LibLexicon.MANA_SPREADER, categoryMana); - spreader.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_SPREADER), new PageText("2"), new PageText("3"), new PageText("4"), new PageText("11"), new PageCraftingRecipe("5", ModCraftingRecipes.recipesSpreader)); + spreader.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_SPREADER), new PageText("2"), new PageText("3"), new PageText("4"), new PageText("11"), new PageCraftingRecipe("5", ModCraftingRecipes.recipesSpreader), new PageText("10")); pool = new BLexiconEntry(LibLexicon.MANA_POOL, categoryMana); pool.setPriority().setLexiconPages(new PageText("0"), new PageText("9"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePool), new PageManaInfusionRecipe("10", ModManaInfusionRecipes.poolRecipe), new PageText("2"), new PageText("8"), new PageManaInfusionRecipe("3", ModManaInfusionRecipes.manasteelRecipes), new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaPearlRecipe), new PageManaInfusionRecipe("5", ModManaInfusionRecipes.manaDiamondRecipes), new PageManaInfusionRecipe("6", ModManaInfusionRecipes.manaPetalRecipes), new PageManaInfusionRecipe("11", ModManaInfusionRecipes.managlassRecipe), new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaStringRecipe), new PageManaInfusionRecipe("7", ModManaInfusionRecipes.manaCookieRecipe)).setIcon(new ItemStack(ModBlocks.pool)); diff --git a/src/main/resources/assets/botania/lang/en_US.lang b/src/main/resources/assets/botania/lang/en_US.lang index 48786ffb7..ce2a25a46 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -1245,6 +1245,7 @@ botania.page.spreader3=Holding a &1Wand of the Forest&0 displays a beam which sh botania.page.spreader4=The spreader only fires one burst at once, it'll only fire another one when the last one hits the target.
Furthermore, the bursts also start suffering &4mana loss&0 after a small amount of time. This can be seen in the beam, which becomes a lot thinner when this happens. There is also a small amount of &4mana loss&0 when a beam enters a spreader. botania.page.spreader11=Applying a &4Redstone Signal&0 to the spreader will have it cease to function. Case better control is required, a &1Redstone Mana Spreader&0 is recommended, as it can fire bursts without a target block and works on redstone pulses. botania.page.spreader5=Crafting the &1Mana Spreader&0 +botania.page.spreader10=Right clicking the spreader with a piece of &1Wool&0 will sleeve it. Aside from making it look fancier, it'll also muffle the sound when a burst is shot, making it much less obnoxious when there's a large amount of spreaders in one area.
Right clicking with an empty hand will remove the sleeve. # -- MANA POOL botania.entry.pool=Mana Pool