mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-27 23:45:57 +00:00
Rune altar render and name.
This commit is contained in:
1 parent
a27416eace
commit
62c0e66c7c
4 files changed
+116
-6
No files matched your search
@@ -11,25 +11,90 @@
|
||||
*/
|
||||
package vazkii.botania.client.render.tile;
|
||||
|
||||
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.ENTITY;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.client.model.ModelSpinningCubes;
|
||||
import vazkii.botania.common.block.tile.TileRuneAltar;
|
||||
|
||||
public class RenderTileRuneAltar extends TileEntitySpecialRenderer {
|
||||
|
||||
ModelSpinningCubes cubes = new ModelSpinningCubes();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) {
|
||||
TileRuneAltar altar = (TileRuneAltar) tileentity;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glTranslated(x + 0.5, y + 1.8, z + 0.5);
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
for(int i = 0; i < altar.getSizeInventory(); i++) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glTranslatef(1F, 1.5F, 1F);
|
||||
GL11.glRotatef(altar.angles[i], 0F, 1F, 0F);
|
||||
GL11.glTranslatef(1.25F, 0F, 0.5F);
|
||||
GL11.glRotatef(90F, 0F, 1F, 0F);
|
||||
GL11.glTranslated(0D, 0.1 * Math.sin((double) (tileentity.worldObj.getTotalWorldTime() + i * 10) / 5D), 0F);
|
||||
ItemStack stack = altar.getStackInSlot(i);
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if(stack != null) {
|
||||
mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
|
||||
|
||||
if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.blocksList[stack.itemID].getRenderType())) {
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glTranslatef(1F, 1.1F, 0F);
|
||||
new RenderBlocks().renderBlockAsItem(Block.blocksList[stack.itemID], stack.getItemDamage(), 1F);
|
||||
GL11.glTranslatef(-1F, -1.1F, 0F);
|
||||
GL11.glScalef(2F, 2F, 2F);
|
||||
} else {
|
||||
int renderPass = 0;
|
||||
do {
|
||||
Icon icon = stack.getItem().getIcon(stack, renderPass);
|
||||
if(icon != null) {
|
||||
Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));
|
||||
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
|
||||
float f = icon.getMinU();
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
}
|
||||
renderPass++;
|
||||
} while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
|
||||
}
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0.5, 1.8, 0.5);
|
||||
GL11.glRotatef(180F, 1F, 0F, 1F);
|
||||
int repeat = 15;
|
||||
cubes.renderSpinningCubes(2, repeat, repeat);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.util.Random;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
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;
|
||||
@@ -60,6 +61,17 @@ public class BlockRuneAltar extends BlockModContainer {
|
||||
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
|
||||
ItemStack stack = par5EntityPlayer.getCurrentEquippedItem();
|
||||
if(stack != null) {
|
||||
((TileRuneAltar) par1World.getBlockTileEntity(par2, par3, par4)).addItem(par5EntityPlayer, stack);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
|
||||
TileSimpleInventory inv = (TileSimpleInventory) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
@@ -18,6 +18,8 @@ import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class TileRuneAltar extends TileSimpleInventory implements ISidedInventory {
|
||||
|
||||
public float[] angles = new float[getSizeInventory()];
|
||||
|
||||
public void addItem(EntityPlayer player, ItemStack stack) {
|
||||
for(int i = 0; i < getSizeInventory(); i++)
|
||||
if(getStackInSlot(i) == null) {
|
||||
@@ -25,12 +27,43 @@ public class TileRuneAltar extends TileSimpleInventory implements ISidedInventor
|
||||
stackToAdd.stackSize = 1;
|
||||
setInventorySlotContents(i, stackToAdd);
|
||||
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0)
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0)
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
for(int i = 0; i < angles.length; i++)
|
||||
angles[i]++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
super.setInventorySlotContents(i, itemstack);
|
||||
updateRotationAngles();
|
||||
}
|
||||
|
||||
public void updateRotationAngles() {
|
||||
int items = 0;
|
||||
for(int i = 0; i < getSizeInventory(); i++)
|
||||
if(getStackInSlot(i) == null)
|
||||
break;
|
||||
else items++;
|
||||
|
||||
float anglePer = 360F / (float) items;
|
||||
float totalAngle = 0F;
|
||||
for(int i = 0; i < angles.length; i++)
|
||||
angles[i] = (totalAngle += anglePer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 16;
|
||||
|
||||
@@ -55,7 +55,7 @@ tile.botania:livingrock.name=Livingrock
|
||||
tile.botania:livingwood.name=Livingwood
|
||||
tile.botania:spreader.name=Mana Spreader
|
||||
tile.botania:pool.name=Mana Pool
|
||||
tile.botania.runeAltar.name=Runic Altar
|
||||
tile.botania:runeAltar.name=Runic Altar
|
||||
|
||||
# FLOWER NAMES
|
||||
tile.botania:flower..name=Botania Flower
|
||||
|
||||
Reference in new issue
Block a user