mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 19:59:36 +00:00
Hourglass render smoothening and addition of Mana Powder to make it a counter.
This commit is contained in:
1 parent
87266364c8
commit
50ad1301d7
6 files changed
+45
-17
No files matched your search
@@ -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);
|
||||
|
||||
@@ -48,8 +48,9 @@ public class RenderTileHourglass extends TileEntitySpecialRenderer<TileHourglass
|
||||
float z = 0.5F + (float) Math.sin(time * 0.05F) * 0.025F;
|
||||
ItemStack stack = hasWorld ? hourglass.getItemHandler().getStackInSlot(0) : null;
|
||||
|
||||
float fract1 = stack == null ? 0 : hourglass.timeFraction;
|
||||
float fract2 = stack == null ? 0 : 1F - hourglass.timeFraction;
|
||||
float activeFraction = stack == null ? 0 : hourglass.lastFraction + (hourglass.timeFraction - hourglass.lastFraction) * ticks;
|
||||
float fract1 = stack == null ? 0 : activeFraction;
|
||||
float fract2 = stack == null ? 0 : 1F - activeFraction;
|
||||
GlStateManager.translate(x, y, z);
|
||||
|
||||
float rot = hasWorld && hourglass.flip ? 180F : 1F;
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
@@ -17,11 +21,9 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMap;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -36,7 +38,6 @@ import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.mana.IManaTrigger;
|
||||
@@ -51,9 +52,6 @@ import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable, IWandHUD, ILexiconable {
|
||||
|
||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(0.25, 0, 0.25, 0.75, 1.15, 0.75);
|
||||
@@ -181,10 +179,9 @@ public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable,
|
||||
|
||||
@Override
|
||||
public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) {
|
||||
if(!world.isRemote && !burst.isFake()) {
|
||||
if(!burst.isFake()) {
|
||||
TileHourglass tile = (TileHourglass) world.getTileEntity(pos);
|
||||
tile.move = !tile.move;
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile);
|
||||
tile.onManaCollide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.item.IHourglassTrigger;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
public class TileHourglass extends TileSimpleInventory {
|
||||
|
||||
@@ -40,17 +41,23 @@ public class TileHourglass extends TileSimpleInventory {
|
||||
|
||||
private int time = 0;
|
||||
public float timeFraction = 0F;
|
||||
public float lastFraction = 0;
|
||||
public boolean flip = false;
|
||||
public int flipTicks = 0;
|
||||
public boolean lock = false;
|
||||
public boolean move = true;
|
||||
public boolean dust = false;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
int totalTime = getTotalTime();
|
||||
if(totalTime > 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;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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.<br>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.<br>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.<br>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
|
||||
|
||||
Reference in new issue
Block a user