rotating but not well

This commit is contained in:
KitsuShadow
2015-08-23 06:30:30 -04:00
parent 55e904eb69
commit 89abfb551c
7 changed files with 112 additions and 67 deletions

View File

@@ -9,9 +9,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import nmd.primal.energy.block.lathe.LatheBase;
import nmd.primal.energy.common.ModInfo;
import nmd.primal.energy.render.RenderID;
import nmd.primal.energy.tileents.TileEntCrank;
import nmd.primal.energy.tileents.TileEntLatheBase;
import nmd.primal.energy.util.CustomTab;
public class CrankBlock extends Block implements ITileEntityProvider{
@@ -25,56 +27,62 @@ public class CrankBlock extends Block implements ITileEntityProvider{
this.setResistance(6.0F);
this.setStepSound(soundTypeStone);
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) {
//if(!world.isRemote){
///if(!world.isRemote){
System.out.println(world.getBlockMetadata(x, y, z));
TileEntCrank tile = (TileEntCrank) world.getTileEntity(x, y, z);
if(tile.isPowered == false){
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;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
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;
}
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);
//}
}
if ((double)y - d0 > 0.0D)
{
return 0;
}
}
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)));
}
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;

View File

@@ -1,9 +1,12 @@
package nmd.primal.energy.item;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import nmd.primal.energy.block.ModBlocks;
import nmd.primal.energy.common.ModInfo;
import nmd.primal.energy.util.CustomTab;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -12,6 +15,7 @@ public class SChiselItem extends Item{
private String name = "schiselItem";
private Item item;
private boolean doWork;
public SChiselItem(){
setMaxStackSize(1);
@@ -27,32 +31,16 @@ public class SChiselItem extends Item{
@Override
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
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
player.setItemInUse(stack, 72000);
//player.setItemInUse(stack, 72000);
if(!world.isRemote){
}
return stack;
}

View File

@@ -66,6 +66,7 @@ public class RenderCrank extends TileEntitySpecialRenderer {
GL11.glScalef(scale, scale, scale);
GL11.glTranslatef(1.0F, 0.48F, 1.0F);
if(tl.isPowered == true){
GL11.glRotatef(i, 0.0F, 1.0F, 0.0F);
@@ -79,8 +80,6 @@ public class RenderCrank extends TileEntitySpecialRenderer {
}
}
//
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
this.model.renderAll();

View File

@@ -4,7 +4,10 @@ import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
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.entity.item.EntityItem;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
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 TEXTURE = new ResourceLocation("energy:models/FlintLathe.png");
private IModelCustom model = AdvancedModelLoader.loadModel(MODEL);
EntityItem entItem = null;
@Override
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);
TileEntLatheBase tile = (TileEntLatheBase) tileEnt;
tile.markForUpdate();
tile.markDirty();
renderBlock(tile, tileEnt.getWorldObj(), tileEnt.xCoord,tileEnt.yCoord, tileEnt.zCoord, ModBlocks.flintLathe);
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();
@@ -41,19 +48,39 @@ public class RenderLathe extends TileEntitySpecialRenderer {
GL11.glScalef(scale, scale, scale);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
/*if(tl.isPowered == true){
GL11.glRotatef(i, 0.0F, 1.0F, 0.0F);
a++;
if(a==1){
i=i+7;
a=0;
if(tile.getStackInSlot(0) != null){
entItem = new EntityItem(tile.getWorldObj(), x, y, z, tile.getStackInSlot(0));
GL11.glPushMatrix();
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){
i=0;
if(tile.isPowered==false){
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);
this.model.renderAll();

View File

@@ -11,7 +11,7 @@ import net.minecraft.world.World;
public class TileBase extends TileEntity{
protected String specName;
public boolean isPowered;
public boolean isPowered = true;
public TileBase(String name){
specName = name;
@@ -23,11 +23,13 @@ public class TileBase extends TileEntity{
@Override
public void updateEntity() {
System.out.println(isPowered);
World world = this.getWorldObj();
int x = this.xCoord;
int y = this.yCoord;
int z = this.zCoord;
if (worldObj.isRemote) return;
}
@Override

View File

@@ -23,10 +23,12 @@ public class TileEntCrank extends TileBase {
if(i>16){
this.isPowered=false;
i=0;
this.markDirty();
this.markForUpdate();
}
}
if (worldObj.isRemote) return;
//System.out.println(this.isPowered + " " + i);
System.out.println(this.isPowered + " " + i);
}
/*@Override

View File

@@ -5,10 +5,12 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
public class TileEntLatheBase extends TileBase implements IInventory {
private ItemStack[] inv;
private int i;
public TileEntLatheBase(String name) {
super(name);
@@ -24,6 +26,23 @@ public class TileEntLatheBase extends TileBase implements IInventory {
public ItemStack getStackInSlot(int 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
public ItemStack decrStackSize(int slot, int amount) {