mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-14 01:04:16 +00:00
Finish off the Hourglass.
This commit is contained in:
1 parent
40237cdb66
commit
fbeea5007e
7 files changed
+164
-4
No files matched your search
@@ -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.RenderHourglass;
|
||||
import vazkii.botania.client.render.block.RenderIncensePlate;
|
||||
import vazkii.botania.client.render.block.RenderPool;
|
||||
import vazkii.botania.client.render.block.RenderPump;
|
||||
@@ -205,6 +206,7 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderingRegistry.registerBlockHandler(new RenderDoubleFlower());
|
||||
RenderingRegistry.registerBlockHandler(new RenderCorporeaCrystalCube());
|
||||
RenderingRegistry.registerBlockHandler(new RenderIncensePlate());
|
||||
RenderingRegistry.registerBlockHandler(new RenderHourglass());
|
||||
|
||||
RenderTransparentItem renderTransparentItem = new RenderTransparentItem();
|
||||
RenderFloatingFlowerItem renderFloatingFlower = new RenderFloatingFlowerItem();
|
||||
|
||||
@@ -69,6 +69,7 @@ public class ModelHourglass extends ModelBase {
|
||||
base2.render(f);
|
||||
Color c = new Color(color);
|
||||
GL11.glColor3ub((byte) c.getRed(), (byte) c.getGreen(), (byte) c.getBlue());
|
||||
boolean normalize = GL11.glGetBoolean(GL11.GL_NORMALIZE);
|
||||
GL11.glEnable(GL11.GL_NORMALIZE);
|
||||
|
||||
if(fract1 > 0) {
|
||||
@@ -99,7 +100,8 @@ public class ModelHourglass extends ModelBase {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_NORMALIZE);
|
||||
if(!normalize)
|
||||
GL11.glDisable(GL11.GL_NORMALIZE);
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
glass1.render(f);
|
||||
glass2.render(f);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. 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 30, 2015, 3:17:41 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.common.block.tile.TileHourglass;
|
||||
import vazkii.botania.common.block.tile.mana.TileSpreader;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
public class RenderHourglass implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileHourglass(), 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.idHourglass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class RenderTileHourglass extends TileEntitySpecialRenderer {
|
||||
model = new ModelHourglass();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
//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);
|
||||
|
||||
@@ -14,21 +14,30 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.mana.IManaTrigger;
|
||||
import vazkii.botania.api.wand.IWandHUD;
|
||||
import vazkii.botania.api.wand.IWandable;
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import vazkii.botania.common.block.tile.TileHourglass;
|
||||
import vazkii.botania.common.block.tile.TileSimpleInventory;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockHourglass extends BlockModContainer {
|
||||
public class BlockHourglass extends BlockModContainer implements IManaTrigger, IWandable, IWandHUD {
|
||||
|
||||
Random random;
|
||||
|
||||
@@ -51,6 +60,15 @@ public class BlockHourglass extends BlockModContainer {
|
||||
TileHourglass hourglass = (TileHourglass) world.getTileEntity(x, y, z);
|
||||
ItemStack hgStack = hourglass.getStackInSlot(0);
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if(stack != null && stack.getItem() == ModItems.twigWand)
|
||||
return false;
|
||||
|
||||
if(hourglass.lock) {
|
||||
if(!player.worldObj.isRemote)
|
||||
player.addChatMessage(new ChatComponentTranslation("botaniamisc.hourglassLock"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(hgStack == null && hourglass.getStackItemTime(stack) > 0) {
|
||||
hourglass.setInventorySlotContents(0, stack.copy());
|
||||
hourglass.markDirty();
|
||||
@@ -155,5 +173,27 @@ public class BlockHourglass extends BlockModContainer {
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileHourglass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBurstCollision(IManaBurst burst, World world, int x, int y, int z) {
|
||||
if(!world.isRemote && !burst.isFake()) {
|
||||
TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z);
|
||||
tile.move = !tile.move;
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
|
||||
TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z);
|
||||
tile.lock = !tile.lock;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
|
||||
TileHourglass tile = (TileHourglass) world.getTileEntity(x, y, z);
|
||||
tile.renderHUD(res);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,20 +10,42 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class TileHourglass extends TileSimpleInventory {
|
||||
|
||||
private static final String TAG_TIME = "time";
|
||||
private static final String TAG_TIME_FRACTION = "timeFraction";
|
||||
private static final String TAG_FLIP = "flip";
|
||||
private static final String TAG_FLIP_TICKS = "flipTicks";
|
||||
private static final String TAG_LOCK = "lock";
|
||||
private static final String TAG_MOVE = "move";
|
||||
|
||||
int time = 0;
|
||||
public float timeFraction = 0F;
|
||||
public boolean flip = false;
|
||||
public int flipTicks = 0;
|
||||
public boolean lock = false;
|
||||
public boolean move = true;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
@@ -31,7 +53,8 @@ public class TileHourglass extends TileSimpleInventory {
|
||||
|
||||
int totalTime = getTotalTime();
|
||||
if(totalTime > 0) {
|
||||
time++;
|
||||
if(move)
|
||||
time++;
|
||||
if(time >= totalTime) {
|
||||
time = 0;
|
||||
flip = !flip;
|
||||
@@ -82,12 +105,22 @@ public class TileHourglass extends TileSimpleInventory {
|
||||
public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writeCustomNBT(par1nbtTagCompound);
|
||||
par1nbtTagCompound.setInteger(TAG_TIME, time);
|
||||
par1nbtTagCompound.setFloat(TAG_TIME_FRACTION, timeFraction);
|
||||
par1nbtTagCompound.setBoolean(TAG_FLIP, flip);
|
||||
par1nbtTagCompound.setInteger(TAG_FLIP_TICKS, flipTicks);
|
||||
par1nbtTagCompound.setBoolean(TAG_MOVE, move);
|
||||
par1nbtTagCompound.setBoolean(TAG_LOCK, lock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.readCustomNBT(par1nbtTagCompound);
|
||||
time = par1nbtTagCompound.getInteger(TAG_TIME);
|
||||
timeFraction = par1nbtTagCompound.getFloat(TAG_TIME_FRACTION);
|
||||
flip = par1nbtTagCompound.getBoolean(TAG_FLIP);
|
||||
flipTicks = par1nbtTagCompound.getInteger(TAG_FLIP_TICKS);
|
||||
move = par1nbtTagCompound.getBoolean(TAG_MOVE);
|
||||
lock = par1nbtTagCompound.getBoolean(TAG_LOCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,6 +134,35 @@ public class TileHourglass extends TileSimpleInventory {
|
||||
time = 0;
|
||||
timeFraction = 0F;
|
||||
}
|
||||
|
||||
public void renderHUD(ScaledResolution res) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
int x = res.getScaledWidth() / 2 + 10;
|
||||
int y = res.getScaledHeight() / 2 - 10;
|
||||
|
||||
ItemStack stack = getStackInSlot(0);
|
||||
if(stack != null) {
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y);
|
||||
RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y);
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
int time = getTotalTime();
|
||||
String timeStr = StringUtils.ticksToElapsedTime(time);
|
||||
mc.fontRenderer.drawStringWithShadow(timeStr, x + 20, y, getColor());
|
||||
|
||||
String status = "";
|
||||
if(lock)
|
||||
status = "locked";
|
||||
if(!move)
|
||||
status = status.isEmpty() ? "stopped" : "lockedStopped";
|
||||
if(!status.isEmpty())
|
||||
mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("botaniamisc." + status), x + 20, y + 12, getColor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
|
||||
@@ -111,6 +111,10 @@ botaniamisc.active=&aActive
|
||||
botaniamisc.inactive=&cInactive
|
||||
botaniamisc.achievements=Botania Achievements
|
||||
botaniamisc.dropIkea=&bDropping this item will break it down into its components
|
||||
botaniamisc.hourglassLock=This Hourglass is locked. Right click it with a Wand of the Forest to unlock it.
|
||||
botaniamisc.locked=Locked
|
||||
botaniamisc.stopped=Stopped
|
||||
botaniamisc.lockedStopped=Locked, Stopped
|
||||
|
||||
# NEI INTEGRATION
|
||||
botania.nei.brewery=Botanical Brewery
|
||||
|
||||
Reference in new issue
Block a user