mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-13 16:54:06 +00:00
The Tiny Potato can now be named in an anvil.
This commit is contained in:
1 parent
46ddb5fafc
commit
eb27b59c69
3 files changed
+91
-5
No files matched your search
@@ -12,6 +12,9 @@
|
||||
package vazkii.botania.client.render.tile;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -36,26 +39,65 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer {
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glTranslated(d0, d1, d2);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.renderEngine.bindTexture(texture);
|
||||
|
||||
GL11.glTranslatef(0.5F, 1.5F, 0.5F);
|
||||
GL11.glScalef(1F, -1F, -1F);
|
||||
int meta = potato.getWorldObj() == null ? 3 : potato.getBlockMetadata();
|
||||
GL11.glRotatef(meta * 90F - 180F, 0F, 1F, 0F);
|
||||
float rotY = meta * 90F - 180F;
|
||||
GL11.glRotatef(rotY, 0F, 1F, 0F);
|
||||
|
||||
float jump = potato.jumpTicks;
|
||||
if(jump > 0)
|
||||
jump += var8;
|
||||
|
||||
float up = (float) -Math.abs(Math.sin(jump / 10 * Math.PI)) * 0.2F;
|
||||
float rot = (float) Math.sin(jump / 10 * Math.PI) * 2;
|
||||
float rotZ = (float) Math.sin(jump / 10 * Math.PI) * 2;
|
||||
|
||||
GL11.glTranslatef(0F, up, 0F);
|
||||
GL11.glRotatef(rot, 0F, 0F, 1F);
|
||||
GL11.glRotatef(rotZ, 0F, 0F, 1F);
|
||||
|
||||
model.render();
|
||||
|
||||
GL11.glRotatef(-rotZ, 0F, 0F, 1F);
|
||||
GL11.glRotatef(-rotY, 0F, 1F, 0F);
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
GL11.glScalef(1F, -1F, -1F);
|
||||
|
||||
if(!potato.name.isEmpty()) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0F, -0.6F, 0F);
|
||||
GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F);
|
||||
float f = 1.6F;
|
||||
float f1 = 0.016666668F * f;
|
||||
GL11.glScalef(-f1, -f1, f1);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glTranslatef(0.0F, 0F / f1, 0.0F);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
tessellator.startDrawingQuads();
|
||||
int i = mc.fontRenderer.getStringWidth(potato.name) / 2;
|
||||
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
|
||||
tessellator.addVertex((double)(-i - 1), -1.0D, 0.0D);
|
||||
tessellator.addVertex((double)(-i - 1), 8.0D, 0.0D);
|
||||
tessellator.addVertex((double)(i + 1), 8.0D, 0.0D);
|
||||
tessellator.addVertex((double)(i + 1), -1.0D, 0.0D);
|
||||
tessellator.draw();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDepthMask(true);
|
||||
mc.fontRenderer.drawString(potato.name, -mc.fontRenderer.getStringWidth(potato.name) / 2, 0, 0xFFFFFF);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glScalef(1F / -f1, 1F / -f1, 1F / f1);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.decor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -18,6 +20,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
@@ -25,7 +28,9 @@ import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import vazkii.botania.common.block.BlockModContainer;
|
||||
import vazkii.botania.common.block.tile.TileSpecialFlower;
|
||||
import vazkii.botania.common.block.tile.TileTinyPotato;
|
||||
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
@@ -64,6 +69,30 @@ public class BlockTinyPotato extends BlockModContainer implements ILexiconable {
|
||||
int l1 = MathHelper.floor_double(par5EntityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, l1, 2);
|
||||
if (par6ItemStack.hasDisplayName())
|
||||
((TileTinyPotato) par1World.getTileEntity(par2, par3, par4)).name = par6ItemStack.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) {
|
||||
if(!par6EntityPlayer.capabilities.isCreativeMode)
|
||||
dropBlockAsItem(par1World, par2, par3, par4, par5, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null) {
|
||||
ItemStack stack = new ItemStack(this);
|
||||
String name = ((TileTinyPotato) tile).name;
|
||||
if(!name.isEmpty())
|
||||
stack.setStackDisplayName(name);
|
||||
list.add(stack);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,11 +11,16 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
||||
public class TileTinyPotato extends TileMod {
|
||||
|
||||
public int jumpTicks = 0;
|
||||
private static final String TAG_NAME = "name";
|
||||
|
||||
public int jumpTicks = 0;
|
||||
public String name = "";
|
||||
|
||||
public void jump() {
|
||||
if(jumpTicks == 0)
|
||||
jumpTicks = 20;
|
||||
@@ -29,4 +34,14 @@ public class TileTinyPotato extends TileMod {
|
||||
if(jumpTicks > 0)
|
||||
jumpTicks--;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound cmp) {
|
||||
cmp.setString(TAG_NAME, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound cmp) {
|
||||
name = cmp.getString(TAG_NAME);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user