Fixed breaker and placer textures and rotations
|
@ -1,148 +1,207 @@
|
|||
package resonantinduction.mechanical.process.edit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import calclavia.lib.content.module.TileBase;
|
||||
import calclavia.lib.content.module.TileRender;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import calclavia.lib.render.RotatedTextureRenderer;
|
||||
import calclavia.lib.utility.inventory.InternalInventoryHandler;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import universalelectricity.api.vector.VectorWorld;
|
||||
import calclavia.lib.content.module.TileBase;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import calclavia.lib.utility.inventory.InternalInventoryHandler;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/** @author tgame14
|
||||
* @since 18/03/14 */
|
||||
/**
|
||||
* @author tgame14
|
||||
* @since 18/03/14
|
||||
*/
|
||||
public class TileBreaker extends TileBase implements IRotatable, IPacketReceiver
|
||||
{
|
||||
private boolean doWork = false;
|
||||
private InternalInventoryHandler invHandler;
|
||||
private byte place_delay = 0;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static Icon iconFront, iconBack;
|
||||
private boolean doWork = false;
|
||||
private InternalInventoryHandler invHandler;
|
||||
private byte place_delay = 0;
|
||||
|
||||
public TileBreaker()
|
||||
{
|
||||
super(Material.iron);
|
||||
this.rotationMask = Byte.parseByte("111111", 2);
|
||||
}
|
||||
public TileBreaker()
|
||||
{
|
||||
super(Material.iron);
|
||||
normalRender = false;
|
||||
rotationMask = Byte.parseByte("111111", 2);
|
||||
}
|
||||
|
||||
public InternalInventoryHandler getInvHandler()
|
||||
{
|
||||
if (invHandler == null)
|
||||
{
|
||||
invHandler = new InternalInventoryHandler(this);
|
||||
}
|
||||
return invHandler;
|
||||
}
|
||||
public InternalInventoryHandler getInvHandler()
|
||||
{
|
||||
if (invHandler == null)
|
||||
{
|
||||
invHandler = new InternalInventoryHandler(this);
|
||||
}
|
||||
return invHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
{
|
||||
work();
|
||||
}
|
||||
@Override
|
||||
public void onAdded()
|
||||
{
|
||||
work();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
work();
|
||||
}
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
work();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (doWork)
|
||||
{
|
||||
if (place_delay < Byte.MAX_VALUE)
|
||||
{
|
||||
place_delay++;
|
||||
}
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (doWork)
|
||||
{
|
||||
if (place_delay < Byte.MAX_VALUE)
|
||||
{
|
||||
place_delay++;
|
||||
}
|
||||
|
||||
if (place_delay >= 10)
|
||||
{
|
||||
doWork();
|
||||
doWork = false;
|
||||
place_delay = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (place_delay >= 10)
|
||||
{
|
||||
doWork();
|
||||
doWork = false;
|
||||
place_delay = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void work()
|
||||
{
|
||||
if (isIndirectlyPowered())
|
||||
{
|
||||
doWork = true;
|
||||
place_delay = 0;
|
||||
}
|
||||
}
|
||||
public void work()
|
||||
{
|
||||
if (isIndirectlyPowered())
|
||||
{
|
||||
doWork = true;
|
||||
place_delay = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void doWork()
|
||||
{
|
||||
if (isIndirectlyPowered())
|
||||
{
|
||||
ForgeDirection dir = getDirection();
|
||||
Vector3 check = position().translate(dir);
|
||||
VectorWorld put = (VectorWorld) position().translate(dir.getOpposite());
|
||||
public void doWork()
|
||||
{
|
||||
if (isIndirectlyPowered())
|
||||
{
|
||||
ForgeDirection dir = getDirection();
|
||||
Vector3 check = position().translate(dir);
|
||||
VectorWorld put = (VectorWorld) position().translate(dir.getOpposite());
|
||||
|
||||
Block block = Block.blocksList[check.getBlockID(world())];
|
||||
Block block = Block.blocksList[check.getBlockID(world())];
|
||||
|
||||
if (block != null)
|
||||
{
|
||||
int candidateMeta = world().getBlockMetadata(check.intX(), check.intY(), check.intZ());
|
||||
boolean flag = true;
|
||||
if (block != null)
|
||||
{
|
||||
int candidateMeta = world().getBlockMetadata(check.intX(), check.intY(), check.intZ());
|
||||
boolean flag = true;
|
||||
|
||||
//Get items dropped
|
||||
ArrayList<ItemStack> drops = block.getBlockDropped(getWorldObj(), check.intX(), check.intY(), check.intZ(), candidateMeta, 0);
|
||||
//Get items dropped
|
||||
ArrayList<ItemStack> drops = block.getBlockDropped(getWorldObj(), check.intX(), check.intY(), check.intZ(), candidateMeta, 0);
|
||||
|
||||
for (ItemStack stack : drops)
|
||||
{
|
||||
//Insert into tile if one exists
|
||||
ItemStack insert = stack.copy();
|
||||
insert = getInvHandler().storeItem(insert, this.getDirection().getOpposite());
|
||||
//If not spit items into world
|
||||
if (insert != null)
|
||||
{
|
||||
getInvHandler().throwItem(this.getDirection().getOpposite(), insert);
|
||||
}
|
||||
}
|
||||
for (ItemStack stack : drops)
|
||||
{
|
||||
//Insert into tile if one exists
|
||||
ItemStack insert = stack.copy();
|
||||
insert = getInvHandler().storeItem(insert, this.getDirection().getOpposite());
|
||||
//If not spit items into world
|
||||
if (insert != null)
|
||||
{
|
||||
getInvHandler().throwItem(this.getDirection().getOpposite(), insert);
|
||||
}
|
||||
}
|
||||
|
||||
//Destroy block
|
||||
ResonantInduction.proxy.renderBlockParticle(worldObj, check.intX(), check.intY(), check.intZ(), new Vector3((Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3), world().getBlockId(check.intX(), check.intY(), check.intZ()), 1);
|
||||
//Destroy block
|
||||
ResonantInduction.proxy.renderBlockParticle(worldObj, check.intX(), check.intY(), check.intZ(), new Vector3((Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3), world().getBlockId(check.intX(), check.intY(), check.intZ()), 1);
|
||||
|
||||
getWorldObj().destroyBlock(check.intX(), check.intY(), check.intZ(), false);
|
||||
getWorldObj().playAuxSFX(1012, check.intX(), check.intY(), check.intZ(), 0);
|
||||
getWorldObj().destroyBlock(check.intX(), check.intY(), check.intZ(), false);
|
||||
getWorldObj().playAuxSFX(1012, check.intX(), check.intY(), check.intZ(), 0);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, nbt);
|
||||
}
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon(IBlockAccess access, int side)
|
||||
{
|
||||
int meta = access.getBlockMetadata(x(), y(), z());
|
||||
|
||||
if (side == meta)
|
||||
{
|
||||
return iconFront;
|
||||
}
|
||||
else if (side == (meta ^ 1))
|
||||
{
|
||||
return iconBack;
|
||||
}
|
||||
|
||||
return getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon(int side, int meta)
|
||||
{
|
||||
if (side == (meta ^ 1))
|
||||
{
|
||||
return iconFront;
|
||||
}
|
||||
else if (side == meta)
|
||||
{
|
||||
return iconBack;
|
||||
}
|
||||
|
||||
return getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
super.registerIcons(iconRegister);
|
||||
iconFront = iconRegister.registerIcon(getTextureName() + "_front");
|
||||
iconBack = iconRegister.registerIcon(getTextureName() + "_back");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected TileRender newRenderer()
|
||||
{
|
||||
return new RotatedTextureRenderer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,11 @@ import calclavia.lib.network.IPacketReceiver;
|
|||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import calclavia.lib.render.RenderItemOverlayUtility;
|
||||
import calclavia.lib.render.RotatedTextureRenderer;
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
import calclavia.lib.utility.inventory.InternalInventoryHandler;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -22,13 +21,14 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* @author tgame14
|
||||
* @since 18/03/14
|
||||
|
@ -39,10 +39,8 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
private static Icon iconFront, iconBack;
|
||||
private boolean doWork = false;
|
||||
private boolean autoPullItems = false;
|
||||
private byte place_delay = 0;
|
||||
private byte placeDelay = 0;
|
||||
private InternalInventoryHandler invHandler;
|
||||
private ForgeDirection renderItemSideA;
|
||||
private ForgeDirection renderItemSideB;
|
||||
|
||||
public TilePlacer()
|
||||
{
|
||||
|
@ -77,7 +75,6 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
public void initiate()
|
||||
{
|
||||
super.initiate();
|
||||
updateDirection();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,12 +89,12 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
}
|
||||
if (doWork)
|
||||
{
|
||||
if (place_delay < Byte.MAX_VALUE)
|
||||
if (placeDelay < Byte.MAX_VALUE)
|
||||
{
|
||||
place_delay++;
|
||||
placeDelay++;
|
||||
}
|
||||
|
||||
if (place_delay >= 5)
|
||||
if (placeDelay >= 5)
|
||||
{
|
||||
doWork();
|
||||
doWork = false;
|
||||
|
@ -111,7 +108,7 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
if (isIndirectlyPowered())
|
||||
{
|
||||
doWork = true;
|
||||
place_delay = 0;
|
||||
placeDelay = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,51 +188,44 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setDirection(ForgeDirection direction)
|
||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
||||
{
|
||||
super.setDirection(direction);
|
||||
this.updateDirection();
|
||||
return side == this.getDirection().getOpposite() && slot == 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public void updateDirection()
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon(IBlockAccess access, int side)
|
||||
{
|
||||
switch (this.getDirection())
|
||||
{
|
||||
case EAST:
|
||||
case WEST:
|
||||
this.renderItemSideA = ForgeDirection.NORTH;
|
||||
this.renderItemSideB = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
this.renderItemSideA = ForgeDirection.EAST;
|
||||
this.renderItemSideB = ForgeDirection.WEST;
|
||||
break;
|
||||
int meta = access.getBlockMetadata(x(), y(), z());
|
||||
|
||||
if (side == meta)
|
||||
{
|
||||
return iconFront;
|
||||
}
|
||||
else if (side == (meta ^ 1))
|
||||
{
|
||||
return iconBack;
|
||||
}
|
||||
|
||||
return getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon(int side, int meta)
|
||||
{
|
||||
if (side == meta)
|
||||
if (side == (meta ^ 1))
|
||||
{
|
||||
return iconFront;
|
||||
}
|
||||
else if (ForgeDirection.getOrientation(meta).getOpposite().ordinal() == side)
|
||||
else if (side == meta)
|
||||
{
|
||||
return iconBack;
|
||||
}
|
||||
return super.getIcon(side, meta);
|
||||
|
||||
return getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
||||
{
|
||||
return side == this.getDirection().getOpposite() && slot == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
@ -250,19 +240,18 @@ public class TilePlacer extends TileInventory implements IRotatable, IPacketRece
|
|||
@SideOnly(Side.CLIENT)
|
||||
protected TileRender newRenderer()
|
||||
{
|
||||
return new TileRender()
|
||||
return new RotatedTextureRenderer(this)
|
||||
{
|
||||
@Override
|
||||
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
|
||||
{
|
||||
if (!isItem)
|
||||
if (world() != null && !isItem)
|
||||
{
|
||||
if (TilePlacer.this.worldObj != null && (TilePlacer.this.renderItemSideA == null || TilePlacer.this.renderItemSideB == null))
|
||||
{
|
||||
TilePlacer.this.updateDirection();
|
||||
}
|
||||
EnumSet set = EnumSet.allOf(ForgeDirection.class);
|
||||
set.remove(getDirection());
|
||||
set.remove(getDirection().getOpposite());
|
||||
GL11.glPushMatrix();
|
||||
RenderItemOverlayUtility.renderItemOnSides(TilePlacer.this, getStackInSlot(0), position.x, position.y, position.z, LanguageUtility.getLocal("tooltip.noOutput"), TilePlacer.this.renderItemSideA, TilePlacer.this.renderItemSideB);
|
||||
RenderItemOverlayUtility.renderItemOnSides(tile(), getStackInSlot(0), position.x, position.y, position.z, LanguageUtility.getLocal("tooltip.noOutput"), set);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 550 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 749 B After Width: | Height: | Size: 4.2 KiB |