Metadata for crank and lathe blend
This commit is contained in:
BIN
Blends/Lathe.blend
Normal file
BIN
Blends/Lathe.blend
Normal file
Binary file not shown.
@@ -3,7 +3,11 @@ package nmd.primal.energy.block;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
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.World;
|
||||
import nmd.primal.energy.common.ModInfo;
|
||||
import nmd.primal.energy.render.RenderID;
|
||||
@@ -20,6 +24,17 @@ public class CrankBlock extends Block implements ITileEntityProvider{
|
||||
this.setHardness(1.0F);
|
||||
this.setResistance(6.0F);
|
||||
this.setStepSound(soundTypeStone);
|
||||
this.setBlockBounds(0.1F, 0.0F, 0.1F,
|
||||
0.9F, 0.75F, 0.9F);
|
||||
}
|
||||
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
|
||||
|
||||
//if(!world.isRemote){
|
||||
System.out.println(world.getBlockMetadata(x, y, z));
|
||||
//}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,6 +42,34 @@ public class CrankBlock extends Block implements ITileEntityProvider{
|
||||
return new TileEntCrank("tileEntCrack");
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack)
|
||||
{
|
||||
int l = determineOrientation(world, x, y, z, player);
|
||||
//if(!world.isRemote){
|
||||
world.setBlockMetadataWithNotify(x, y, z, l, 2);
|
||||
//}
|
||||
}
|
||||
|
||||
public static int determineOrientation(World world, int x, int y, int z, EntityLivingBase player) {
|
||||
if (MathHelper.abs((float)player.posX - (float)x) < 2.0F && MathHelper.abs((float)player.posZ - (float)z) < 2.0F)
|
||||
{
|
||||
double d0 = player.posY + 1.82D - (double)player.yOffset;
|
||||
|
||||
if (d0 - (double)y > 2.0D)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((double)y - d0 > 0.0D)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int l = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
return l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return RenderID.crankID;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package nmd.primal.energy.render.block;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -27,17 +29,44 @@ public class RenderCrank extends TileEntitySpecialRenderer {
|
||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||
TileEntCrank tile = (TileEntCrank) tileEnt;
|
||||
|
||||
if(tile.getBlockMetadata()==0){
|
||||
GL11.glRotatef(180, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(-1.0f, -1.0f, -0.0f);
|
||||
}
|
||||
if(tile.getBlockMetadata()==1){
|
||||
//GL11.glRotatef(180, 0.0f, 0.0f, 1.0f);
|
||||
//GL11.glTranslatef(-1.0f, -1.0f, -0.0f);
|
||||
//GL11.glRotated(45, 0, 1.0f, 0);
|
||||
}
|
||||
if(tile.getBlockMetadata()==2){
|
||||
GL11.glRotatef(-90, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glTranslatef(0.0f, -1.0f, 0.0f);
|
||||
}
|
||||
if(tile.getBlockMetadata()==3){
|
||||
GL11.glRotatef(90, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glTranslatef(0.0f, 0.0f, -1.0f);
|
||||
}
|
||||
if(tile.getBlockMetadata()==4){
|
||||
GL11.glRotatef(90, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -1.0f, 0.0f);
|
||||
}
|
||||
if(tile.getBlockMetadata()==5){
|
||||
GL11.glRotatef(90, 0.0f, 0.0f, -1.0f);
|
||||
GL11.glTranslatef(-1.0f, 0.0f, 0.0f);
|
||||
}
|
||||
renderBlock(tile, tileEnt.getWorldObj(), tileEnt.xCoord,tileEnt.yCoord, tileEnt.zCoord, ModBlocks.crankBlock);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderBlock(TileEntCrank tl, World world, int i, int j,int k, Block block) {
|
||||
public void renderBlock(TileEntCrank tl, World world, int x, int y,int z, Block block) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
float scale = 0.75F;
|
||||
GL11.glScalef(scale, 0.75f, scale);
|
||||
GL11.glTranslatef(0.65F, 0.48F, 0.65F);
|
||||
float scale = 0.5F;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
|
||||
GL11.glTranslatef(1.0F, 0.48F, 1.0F);
|
||||
|
||||
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
|
||||
|
||||
|
||||
@@ -7,10 +7,9 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class TileBase extends TileEntity{
|
||||
public abstract class TileBase extends TileEntity {
|
||||
|
||||
private String specName;
|
||||
private NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
||||
public TileBase(String name){
|
||||
specName = name;
|
||||
@@ -22,30 +21,27 @@ public abstract class TileBase extends TileEntity{
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
World world = getWorldObj();
|
||||
World world = this.getWorldObj();
|
||||
int x = this.xCoord;
|
||||
int y = this.yCoord;
|
||||
int z = this.zCoord;
|
||||
|
||||
if (worldObj.isRemote) return;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
if (nbt.hasKey("CustomName", 8)) {
|
||||
specName = nbt.getString("CustomName");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
}*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
@@ -56,6 +52,6 @@ public abstract class TileBase extends TileEntity{
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readFromNBT(pkt.func_148857_g());
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user