rotating but not well
This commit is contained in:
@@ -9,9 +9,11 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import nmd.primal.energy.block.lathe.LatheBase;
|
||||||
import nmd.primal.energy.common.ModInfo;
|
import nmd.primal.energy.common.ModInfo;
|
||||||
import nmd.primal.energy.render.RenderID;
|
import nmd.primal.energy.render.RenderID;
|
||||||
import nmd.primal.energy.tileents.TileEntCrank;
|
import nmd.primal.energy.tileents.TileEntCrank;
|
||||||
|
import nmd.primal.energy.tileents.TileEntLatheBase;
|
||||||
import nmd.primal.energy.util.CustomTab;
|
import nmd.primal.energy.util.CustomTab;
|
||||||
|
|
||||||
public class CrankBlock extends Block implements ITileEntityProvider{
|
public class CrankBlock extends Block implements ITileEntityProvider{
|
||||||
@@ -25,56 +27,62 @@ public class CrankBlock extends Block implements ITileEntityProvider{
|
|||||||
this.setResistance(6.0F);
|
this.setResistance(6.0F);
|
||||||
this.setStepSound(soundTypeStone);
|
this.setStepSound(soundTypeStone);
|
||||||
this.setBlockBounds(0.1F, 0.0F, 0.1F,
|
this.setBlockBounds(0.1F, 0.0F, 0.1F,
|
||||||
0.9F, 0.75F, 0.9F);
|
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) {
|
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
|
||||||
|
|
||||||
//if(!world.isRemote){
|
///if(!world.isRemote){
|
||||||
System.out.println(world.getBlockMetadata(x, y, z));
|
System.out.println(world.getBlockMetadata(x, y, z));
|
||||||
TileEntCrank tile = (TileEntCrank) world.getTileEntity(x, y, z);
|
TileEntCrank tile = (TileEntCrank) world.getTileEntity(x, y, z);
|
||||||
if(tile.isPowered == false){
|
if(tile.isPowered == false){
|
||||||
tile.isPowered = true;
|
tile.isPowered = true;
|
||||||
}
|
}
|
||||||
|
if(tile.getBlockMetadata()==2){
|
||||||
|
if(world.getBlock(x, y, z+1) instanceof LatheBase){
|
||||||
|
TileEntLatheBase tileLathe = (TileEntLatheBase) world.getTileEntity(x, y, z+1);
|
||||||
|
tileLathe.isPowered=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//return true;
|
||||||
//}
|
//}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World world, int i) {
|
public TileEntity createNewTileEntity(World world, int i) {
|
||||||
return new TileEntCrank("tileEntCrack");
|
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)
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack)
|
||||||
{
|
{
|
||||||
return 1;
|
int l = determineOrientation(world, x, y, z, player);
|
||||||
}
|
//if(!world.isRemote){
|
||||||
|
world.setBlockMetadataWithNotify(x, y, z, l, 2);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
if ((double)y - d0 > 0.0D)
|
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)
|
||||||
return 0;
|
{
|
||||||
}
|
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)));
|
||||||
|
}
|
||||||
|
|
||||||
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
|
@Override
|
||||||
public int getRenderType() {
|
public int getRenderType() {
|
||||||
return RenderID.crankID;
|
return RenderID.crankID;
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package nmd.primal.energy.item;
|
package nmd.primal.energy.item;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import nmd.primal.energy.block.ModBlocks;
|
||||||
import nmd.primal.energy.common.ModInfo;
|
import nmd.primal.energy.common.ModInfo;
|
||||||
import nmd.primal.energy.util.CustomTab;
|
import nmd.primal.energy.util.CustomTab;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
@@ -12,6 +15,7 @@ public class SChiselItem extends Item{
|
|||||||
|
|
||||||
private String name = "schiselItem";
|
private String name = "schiselItem";
|
||||||
private Item item;
|
private Item item;
|
||||||
|
private boolean doWork;
|
||||||
|
|
||||||
public SChiselItem(){
|
public SChiselItem(){
|
||||||
setMaxStackSize(1);
|
setMaxStackSize(1);
|
||||||
@@ -27,32 +31,16 @@ public class SChiselItem extends Item{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int count) {
|
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int count) {
|
||||||
System.out.println(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called each tick while using an item.
|
|
||||||
* @param stack The Item being used
|
|
||||||
* @param player The Player using the item
|
|
||||||
* @param count The amount of time in tick the item has been used for continuously
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
|
|
||||||
/*
|
|
||||||
* CLIENTSIDE
|
|
||||||
* PlayerObjectMovingPosition to check the block the player is using this against.
|
|
||||||
*
|
|
||||||
* SERVERSIDE
|
|
||||||
* Do Something to the inventory of the itemstack
|
|
||||||
* or
|
|
||||||
* maybe send PacketMessage to change the inventory
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||||
{
|
{
|
||||||
player.setItemInUse(stack, 72000);
|
//player.setItemInUse(stack, 72000);
|
||||||
|
if(!world.isRemote){
|
||||||
|
|
||||||
|
}
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ public class RenderCrank extends TileEntitySpecialRenderer {
|
|||||||
GL11.glScalef(scale, scale, scale);
|
GL11.glScalef(scale, scale, scale);
|
||||||
|
|
||||||
GL11.glTranslatef(1.0F, 0.48F, 1.0F);
|
GL11.glTranslatef(1.0F, 0.48F, 1.0F);
|
||||||
|
|
||||||
if(tl.isPowered == true){
|
if(tl.isPowered == true){
|
||||||
|
|
||||||
GL11.glRotatef(i, 0.0F, 1.0F, 0.0F);
|
GL11.glRotatef(i, 0.0F, 1.0F, 0.0F);
|
||||||
@@ -79,8 +80,6 @@ public class RenderCrank extends TileEntitySpecialRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
|
||||||
|
|
||||||
this.model.renderAll();
|
this.model.renderAll();
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import org.lwjgl.opengl.GL11;
|
|||||||
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -20,6 +23,7 @@ public class RenderLathe extends TileEntitySpecialRenderer {
|
|||||||
public static final ResourceLocation MODEL = new ResourceLocation("energy:models/Lathe.obj");
|
public static final ResourceLocation MODEL = new ResourceLocation("energy:models/Lathe.obj");
|
||||||
public static final ResourceLocation TEXTURE = new ResourceLocation("energy:models/FlintLathe.png");
|
public static final ResourceLocation TEXTURE = new ResourceLocation("energy:models/FlintLathe.png");
|
||||||
private IModelCustom model = AdvancedModelLoader.loadModel(MODEL);
|
private IModelCustom model = AdvancedModelLoader.loadModel(MODEL);
|
||||||
|
EntityItem entItem = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tileEnt, double x, double y, double z, float scale) {
|
public void renderTileEntityAt(TileEntity tileEnt, double x, double y, double z, float scale) {
|
||||||
@@ -29,11 +33,14 @@ public class RenderLathe extends TileEntitySpecialRenderer {
|
|||||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||||
TileEntLatheBase tile = (TileEntLatheBase) tileEnt;
|
TileEntLatheBase tile = (TileEntLatheBase) tileEnt;
|
||||||
|
|
||||||
|
tile.markForUpdate();
|
||||||
|
tile.markDirty();
|
||||||
|
|
||||||
renderBlock(tile, tileEnt.getWorldObj(), tileEnt.xCoord,tileEnt.yCoord, tileEnt.zCoord, ModBlocks.flintLathe);
|
renderBlock(tile, tileEnt.getWorldObj(), tileEnt.xCoord,tileEnt.yCoord, tileEnt.zCoord, ModBlocks.flintLathe);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderBlock(TileEntLatheBase tl, World world, int x, int y,int z, Block block) {
|
public void renderBlock(TileEntLatheBase tile, World world, int x, int y,int z, Block block) {
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
@@ -41,19 +48,39 @@ public class RenderLathe extends TileEntitySpecialRenderer {
|
|||||||
GL11.glScalef(scale, scale, scale);
|
GL11.glScalef(scale, scale, scale);
|
||||||
|
|
||||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||||
/*if(tl.isPowered == true){
|
|
||||||
|
|
||||||
GL11.glRotatef(i, 0.0F, 1.0F, 0.0F);
|
|
||||||
a++;
|
if(tile.getStackInSlot(0) != null){
|
||||||
if(a==1){
|
entItem = new EntityItem(tile.getWorldObj(), x, y, z, tile.getStackInSlot(0));
|
||||||
i=i+7;
|
GL11.glPushMatrix();
|
||||||
a=0;
|
this.entItem.hoverStart = 0.0F;
|
||||||
|
RenderItem.renderInFrame = true;
|
||||||
|
GL11.glScalef(1.0f, 1.0f, 1.0f);
|
||||||
|
GL11.glRotatef(90f, 0.0F, 1.0F, 0.0F);
|
||||||
|
|
||||||
|
if(tile.isPowered == true){
|
||||||
|
|
||||||
|
GL11.glRotatef(i, 1.0F, 0.0F, 0.0F);
|
||||||
|
RenderManager.instance.renderEntityWithPosYaw(entItem, 0.0D, -0.15D, 0.0D, 0.0F, 0.0F);
|
||||||
|
a++;
|
||||||
|
if(a==1){
|
||||||
|
i=i+7;
|
||||||
|
a=0;
|
||||||
|
}
|
||||||
|
if(i==360){
|
||||||
|
i=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(i==360){
|
if(tile.isPowered==false){
|
||||||
i=0;
|
RenderManager.instance.renderEntityWithPosYaw(entItem, 0.0D, -0.15D, 0.0D, 0.0F, 0.0F);
|
||||||
}
|
}
|
||||||
}*/
|
//GL11.glRotatef(90, 0, 1, 0);
|
||||||
|
//RenderManager.instance.renderEntityWithPosYaw(entItem, -0.5D, 0.3D, 0.5D, 0.0F, 0.0F);
|
||||||
|
RenderItem.renderInFrame = false;
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
|
||||||
|
|
||||||
this.model.renderAll();
|
this.model.renderAll();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import net.minecraft.world.World;
|
|||||||
public class TileBase extends TileEntity{
|
public class TileBase extends TileEntity{
|
||||||
|
|
||||||
protected String specName;
|
protected String specName;
|
||||||
public boolean isPowered;
|
public boolean isPowered = true;
|
||||||
|
|
||||||
public TileBase(String name){
|
public TileBase(String name){
|
||||||
specName = name;
|
specName = name;
|
||||||
@@ -23,11 +23,13 @@ public class TileBase extends TileEntity{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
System.out.println(isPowered);
|
||||||
World world = this.getWorldObj();
|
World world = this.getWorldObj();
|
||||||
int x = this.xCoord;
|
int x = this.xCoord;
|
||||||
int y = this.yCoord;
|
int y = this.yCoord;
|
||||||
int z = this.zCoord;
|
int z = this.zCoord;
|
||||||
if (worldObj.isRemote) return;
|
if (worldObj.isRemote) return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ public class TileEntCrank extends TileBase {
|
|||||||
if(i>16){
|
if(i>16){
|
||||||
this.isPowered=false;
|
this.isPowered=false;
|
||||||
i=0;
|
i=0;
|
||||||
|
this.markDirty();
|
||||||
|
this.markForUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (worldObj.isRemote) return;
|
if (worldObj.isRemote) return;
|
||||||
//System.out.println(this.isPowered + " " + i);
|
System.out.println(this.isPowered + " " + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
/*@Override
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import net.minecraft.inventory.IInventory;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class TileEntLatheBase extends TileBase implements IInventory {
|
public class TileEntLatheBase extends TileBase implements IInventory {
|
||||||
|
|
||||||
private ItemStack[] inv;
|
private ItemStack[] inv;
|
||||||
|
private int i;
|
||||||
|
|
||||||
public TileEntLatheBase(String name) {
|
public TileEntLatheBase(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
@@ -24,6 +26,23 @@ public class TileEntLatheBase extends TileBase implements IInventory {
|
|||||||
public ItemStack getStackInSlot(int slot) {
|
public ItemStack getStackInSlot(int slot) {
|
||||||
return this.inv[slot];
|
return this.inv[slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
World world = this.getWorldObj();
|
||||||
|
int x = this.xCoord;
|
||||||
|
int y = this.yCoord;
|
||||||
|
int z = this.zCoord;
|
||||||
|
if(this.isPowered==true){
|
||||||
|
i++;
|
||||||
|
if(i>16){
|
||||||
|
this.isPowered=false;
|
||||||
|
i=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (worldObj.isRemote) return;
|
||||||
|
//System.out.println(this.isPowered + " " + i);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int slot, int amount) {
|
public ItemStack decrStackSize(int slot, int amount) {
|
||||||
|
|||||||
Reference in New Issue
Block a user