mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-03-14 05:35:35 +00:00
97 lines
3.3 KiB
Java
97 lines
3.3 KiB
Java
package com.hbm.blocks.machine.rbmk;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
import com.hbm.render.block.ISBRHUniversal;
|
|
import com.hbm.render.util.RenderBlocksNT;
|
|
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKDisplay;
|
|
|
|
import api.hbm.block.IToolable;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockContainer;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.MathHelper;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
|
|
public class RBMKDisplay extends BlockContainer implements ISBRHUniversal, IToolable {
|
|
|
|
public RBMKDisplay() {
|
|
super(Material.iron);
|
|
}
|
|
|
|
@Override public int getRenderType() { return renderID; }
|
|
@Override public boolean isOpaqueCube() { return false; }
|
|
@Override public boolean renderAsNormalBlock() { return false; }
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public TileEntity createNewTileEntity(World world, int meta) {
|
|
return new TileEntityRBMKDisplay();
|
|
}
|
|
|
|
@Override
|
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
|
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
|
if(i == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
|
if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
|
if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
|
if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
|
}
|
|
|
|
@Override
|
|
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
|
if(tool != ToolType.SCREWDRIVER)
|
|
return false;
|
|
if(!world.isRemote) {
|
|
TileEntity tile = world.getTileEntity(x, y, z);
|
|
if (tile instanceof TileEntityRBMKDisplay) {
|
|
((TileEntityRBMKDisplay) tile).rotate();
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void renderInventoryBlock(Block block, int meta, int modelId, Object renderBlocks) {
|
|
|
|
GL11.glPushMatrix();
|
|
RenderBlocks renderer = (RenderBlocks) renderBlocks;
|
|
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
|
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
|
|
|
renderer.setRenderBounds(0.25D, 0D, 0D, 1D, 1D, 1D);
|
|
RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
|
|
GL11.glPopMatrix();
|
|
}
|
|
|
|
@Override
|
|
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, Object renderBlocks) {
|
|
RenderBlocksNT renderer = RenderBlocksNT.INSTANCE.setWorld(world);
|
|
|
|
Tessellator tessellator = Tessellator.instance;
|
|
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
|
tessellator.setColorOpaque_F(1, 1, 1);
|
|
|
|
int meta = world.getBlockMetadata(x, y, z);
|
|
|
|
renderer.setRenderBounds(meta == 4 ? 0.25D : 0D, 0D, meta == 2 ? 0.25D : 0D, meta == 5 ? 0.75D : 1D, 1D, meta == 3 ? 0.75D : 1D);
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
return true;
|
|
}
|
|
}
|