From 50ad1301d7cb1fb8df192fcdfc92062bf67b6652 Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Thu, 29 Sep 2016 22:04:23 +0100 Subject: [PATCH] Hourglass render smoothening and addition of Mana Powder to make it a counter. --- .../botania/client/model/ModelHourglass.java | 9 ++++-- .../render/tile/RenderTileHourglass.java | 5 ++-- .../botania/common/block/BlockHourglass.java | 15 ++++------ .../common/block/tile/TileHourglass.java | 30 +++++++++++++++++-- .../botania/common/lexicon/LexiconData.java | 2 +- .../resources/assets/botania/lang/en_US.lang | 1 + 6 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/main/java/vazkii/botania/client/model/ModelHourglass.java b/src/main/java/vazkii/botania/client/model/ModelHourglass.java index fd71cce21..4782dc857 100644 --- a/src/main/java/vazkii/botania/client/model/ModelHourglass.java +++ b/src/main/java/vazkii/botania/client/model/ModelHourglass.java @@ -66,9 +66,11 @@ public class ModelHourglass extends ModelBase { base2.render(f); Color c = new Color(color); GL11.glColor3ub((byte) c.getRed(), (byte) c.getGreen(), (byte) c.getBlue()); + GL11.glPushAttrib(GL11.GL_TRANSFORM_BIT); + GlStateManager.disableRescaleNormal(); GlStateManager.enableNormalize(); - + if(fract1 > 0) { GlStateManager.pushMatrix(); if(flip) @@ -92,12 +94,15 @@ public class ModelHourglass extends ModelBase { GlStateManager.translate(-2.5F * f, 1.0F * f, -2.5F * f); } + GlStateManager.scale(1F, fract2, 1F); + sand2.render(f); GlStateManager.popMatrix(); } + + GlStateManager.popAttrib(); - GL11.glPopAttrib(); GL11.glColor3ub(((byte) 255), ((byte) 255), ((byte) 255)); glass1.render(f); glass2.render(f); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java index 236fe9e33..68b612189 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java @@ -48,8 +48,9 @@ public class RenderTileHourglass extends TileEntitySpecialRenderer 0) { - if(move) + ItemStack dustStack = itemHandler.getStackInSlot(0); + dust = dustStack != null && dustStack.getItem() == ModItems.manaResource; + + if(totalTime > 0 || dust) { + if(move && !dust) time++; + if(time >= totalTime) { time = 0; flip = !flip; @@ -68,15 +75,27 @@ public class TileHourglass extends TileSimpleInventory { ((IHourglassTrigger) state.getBlock()).onTriggeredByHourglass(worldObj, pos, this); } } + + lastFraction = timeFraction; timeFraction = (float) time / (float) totalTime; } else { time = 0; + lastFraction = 0F; timeFraction = 0F; } if(flipTicks > 0) flipTicks--; } + + public void onManaCollide() { + if(!worldObj.isRemote) { + if(dust) + time++; + else move = !move; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } + } public int getTotalTime() { ItemStack stack = itemHandler.getStackInSlot(0); @@ -93,6 +112,8 @@ public class TileHourglass extends TileSimpleInventory { return stack.getItemDamage() == 1 ? 200 : 20; if(stack.getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND)) return 1200; + if(stack.getItem() == ModItems.manaResource) + return 1; return 0; } @@ -104,6 +125,9 @@ public class TileHourglass extends TileSimpleInventory { return stack.getItemDamage() == 1 ? 0xE95800 : 0xFFEC49; if(stack.getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND)) return 0x5A412f; + if(stack.getItem() == ModItems.manaResource) + return 0x03abff; + return 0; } @@ -112,7 +136,7 @@ public class TileHourglass extends TileSimpleInventory { return new SimpleItemStackHandler(this, true) { @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - if(stack != null && (stack.getItem() == Item.getItemFromBlock(Blocks.SAND) || stack.getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND))) + if(stack != null && (stack.getItem() == Item.getItemFromBlock(Blocks.SAND) || stack.getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND)) || (stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 23)) return super.insertItem(slot, stack, simulate); else return stack; } diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index ac5bcfdf3..9e503d5a8 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -805,7 +805,7 @@ public final class LexiconData { hourglass = new BasicLexiconEntry(LibLexicon.DEVICE_HOURGLASS, categoryDevices); hourglass.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageText("3"), new PageText("4"), new PageCraftingRecipe("5", ModCraftingRecipes.recipeHourglass)); + new PageText("3"), new PageText("4"), new PageText("6"), new PageCraftingRecipe("5", ModCraftingRecipes.recipeHourglass)); ghostRail = new AlfheimLexiconEntry(LibLexicon.DEVICE_GHOST_RAIL, categoryDevices); ghostRail.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeGhostRail)); diff --git a/src/main/resources/assets/botania/lang/en_US.lang b/src/main/resources/assets/botania/lang/en_US.lang index 1e3f1de7c..d845a9596 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -2746,6 +2746,7 @@ botania.page.hourglass1=The hourglass contains an inventory, in which up to a st botania.page.hourglass2=The amount of time for each pulse is dependent on how much and what type of sand is in the chamber. &1Sand&0 will count for one second per block, &1Red Sand&0 ten seconds per and &1Soul Sand&0 one minute per. Sand types can't be mixed. The time for each pulse can be seen by hovering over the block with a &1Wand of the Forest&0. botania.page.hourglass3=Note that the sand is added all at once, so the size of the stack to be added needs to be set in the inventory.
Sand can't be added to the hourglass after it already has some in, trying to do so will end up removing the sand there instead. The sand in the block can be taken and added by &1Hoppers&0 or other methods. botania.page.hourglass4=Right clicking the block with a &1Wand of the Forest&0 locks (and unlocks) it. When locked, sand can't be added or removed, just in case someone right clicks it on accident.
If a &4Mana Burst&0 collides with the block, it'll stop the flow of sand and pause the timer, colliding again continues it. +botania.page.hourglass6=While a type of sand is the norm, &1Mana Powder&0 can be used instead. Doing this turns the hourglass from a &4timer&0 into a &4counter&0.
Instead of dropping the sand down at a regular interval, it'll drop a single piece down every time a &4Mana Burst&0 collides with it. For example, having ten pieces of powder in it would require 10 bursts for a pulse. botania.page.hourglass5=The sands of time # -- SPECTRAL RAIL