Globalized ability to invert filter
Globalized colored float text depending on inversion
This commit is contained in:
parent
800684f553
commit
3842d4a81e
25 changed files with 191 additions and 169 deletions
|
@ -9,7 +9,7 @@ import org.lwjgl.opengl.GL11;
|
|||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.TranslationHelper;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.machine.filter.ContainerImprinter;
|
||||
import assemblyline.common.machine.imprinter.ContainerImprinter;
|
||||
|
||||
public class GuiImprinter extends GuiContainer
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderDetector extends RenderFilterable
|
||||
public class RenderDetector extends RenderImprintable
|
||||
{
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
package assemblyline.client.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import assemblyline.common.machine.filter.ItemImprinter;
|
||||
import assemblyline.common.machine.filter.TileEntityFilterable;
|
||||
|
||||
/**
|
||||
* @author Briman0094
|
||||
*/
|
||||
public abstract class RenderFilterable extends TileEntitySpecialRenderer
|
||||
{
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityFilterable)
|
||||
{
|
||||
TileEntityFilterable tileFilterable = (TileEntityFilterable) tileEntity;
|
||||
|
||||
ItemStack filter = tileFilterable.getFilter();
|
||||
|
||||
if (filter != null)
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
MovingObjectPosition objectPosition = player.rayTrace(5, 1);
|
||||
|
||||
if (objectPosition != null)
|
||||
{
|
||||
if (objectPosition.blockX == tileFilterable.xCoord && objectPosition.blockY == tileFilterable.yCoord && objectPosition.blockZ == tileFilterable.zCoord)
|
||||
{
|
||||
ArrayList<ItemStack> filters = ItemImprinter.getFilters(filter);
|
||||
for (int i = 0; i < filters.size(); i++)
|
||||
{
|
||||
RenderHelper.renderFloatingText(filters.get(i).getTooltip(player, Minecraft.getMinecraft().gameSettings.advancedItemTooltips).get(0).toString(), (float) x + 0.5f, ((float) y + (i * 0.25f)) - 1f, (float) z + 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -13,10 +13,15 @@ import org.lwjgl.opengl.GL11;
|
|||
*/
|
||||
public class RenderHelper
|
||||
{
|
||||
public static void renderFloatingText(String text, float x, float y, float z)
|
||||
{
|
||||
renderFloatingText(text, x, y, z, 0xFFFFFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a floating text in a specific position.
|
||||
*/
|
||||
public static void renderFloatingText(String text, float x, float y, float z)
|
||||
public static void renderFloatingText(String text, float x, float y, float z, int color)
|
||||
{
|
||||
RenderManager renderManager = RenderManager.instance;
|
||||
FontRenderer fontRenderer = renderManager.getFontRenderer();
|
||||
|
@ -45,10 +50,10 @@ public class RenderHelper
|
|||
tessellator.addVertex((double) (stringMiddle + 1), (double) (-1 + yOffset), 0.0D);
|
||||
tessellator.draw();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, 553648127);
|
||||
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glDepthMask(true);
|
||||
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, -1);
|
||||
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package assemblyline.client.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import assemblyline.common.machine.imprinter.ItemImprinter;
|
||||
import assemblyline.common.machine.imprinter.TileEntityImprintable;
|
||||
|
||||
/**
|
||||
* @author Briman0094
|
||||
*/
|
||||
public abstract class RenderImprintable extends TileEntitySpecialRenderer
|
||||
{
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
{
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityImprintable)
|
||||
{
|
||||
TileEntityImprintable tileFilterable = (TileEntityImprintable) tileEntity;
|
||||
|
||||
ItemStack filter = tileFilterable.getFilter();
|
||||
|
||||
if (filter != null)
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
MovingObjectPosition objectPosition = player.rayTrace(8, 1);
|
||||
|
||||
if (objectPosition != null)
|
||||
{
|
||||
if (objectPosition.blockX == tileFilterable.xCoord && objectPosition.blockY == tileFilterable.yCoord && objectPosition.blockZ == tileFilterable.zCoord)
|
||||
{
|
||||
ArrayList<ItemStack> filters = ItemImprinter.getFilters(filter);
|
||||
for (int i = 0; i < filters.size(); i++)
|
||||
{
|
||||
if (((TileEntityImprintable) tileEntity).isInverted())
|
||||
{
|
||||
RenderHelper.renderFloatingText(filters.get(i).getTooltip(player, Minecraft.getMinecraft().gameSettings.advancedItemTooltips).get(0).toString(), (float) x + 0.5f, ((float) y + (i * 0.25f)) - 1f, (float) z + 0.5f, 0xFF8888);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderHelper.renderFloatingText(filters.get(i).getTooltip(player, Minecraft.getMinecraft().gameSettings.advancedItemTooltips).get(0).toString(), (float) x + 0.5f, ((float) y + (i * 0.25f)) - 1f, (float) z + 0.5f, 0x88FF88);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -9,7 +9,7 @@ import assemblyline.client.model.ModelManipulator;
|
|||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.machine.TileEntityManipulator;
|
||||
|
||||
public class RenderManipulator extends RenderFilterable
|
||||
public class RenderManipulator extends RenderImprintable
|
||||
{
|
||||
private ModelManipulator model = new ModelManipulator();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import assemblyline.client.model.ModelRejector;
|
|||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.machine.TileEntityRejector;
|
||||
|
||||
public class RenderRejector extends RenderFilterable
|
||||
public class RenderRejector extends RenderImprintable
|
||||
{
|
||||
private ModelRejector model = new ModelRejector();
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ import assemblyline.common.block.ItemBlockCrate;
|
|||
import assemblyline.common.machine.BlockManipulator;
|
||||
import assemblyline.common.machine.belt.BlockConveyorBelt;
|
||||
import assemblyline.common.machine.detector.BlockDetector;
|
||||
import assemblyline.common.machine.filter.BlockImprinter;
|
||||
import assemblyline.common.machine.filter.ItemImprinter;
|
||||
import assemblyline.common.machine.imprinter.BlockImprinter;
|
||||
import assemblyline.common.machine.imprinter.ItemImprinter;
|
||||
import assemblyline.common.machine.machine.BlockRejector;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
|
|
|
@ -9,7 +9,7 @@ import assemblyline.common.machine.TileEntityManipulator;
|
|||
import assemblyline.common.machine.TileEntityRejector;
|
||||
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
|
||||
import assemblyline.common.machine.detector.TileEntityDetector;
|
||||
import assemblyline.common.machine.filter.ContainerImprinter;
|
||||
import assemblyline.common.machine.imprinter.ContainerImprinter;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.world.World;
|
|||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.prefab.UETab;
|
||||
import assemblyline.client.render.BlockRenderingHandler;
|
||||
import assemblyline.common.machine.filter.BlockFilterable;
|
||||
import assemblyline.common.machine.imprinter.BlockImprintable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -17,7 +17,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockManipulator extends BlockFilterable
|
||||
public class BlockManipulator extends BlockImprintable
|
||||
{
|
||||
public BlockManipulator(int id)
|
||||
{
|
||||
|
|
|
@ -24,13 +24,13 @@ import universalelectricity.prefab.TranslationHelper;
|
|||
import universalelectricity.prefab.implement.IRedstoneReceptor;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import assemblyline.api.IManipulator;
|
||||
import assemblyline.common.machine.filter.TileEntityFilterable;
|
||||
import assemblyline.common.machine.imprinter.TileEntityImprintable;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
public class TileEntityManipulator extends TileEntityFilterable implements IRedstoneReceptor, IManipulator
|
||||
public class TileEntityManipulator extends TileEntityImprintable implements IRedstoneReceptor, IManipulator
|
||||
{
|
||||
public boolean selfPulse = false;
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.TranslationHelper;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import assemblyline.common.machine.filter.ItemImprinter;
|
||||
import assemblyline.common.machine.filter.TileEntityFilterable;
|
||||
import assemblyline.common.machine.imprinter.ItemImprinter;
|
||||
import assemblyline.common.machine.imprinter.TileEntityImprintable;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -25,7 +25,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
* @author Darkguardsman
|
||||
*
|
||||
*/
|
||||
public class TileEntityRejector extends TileEntityFilterable
|
||||
public class TileEntityRejector extends TileEntityImprintable
|
||||
{
|
||||
/**
|
||||
* should the piston fire, or be extended
|
||||
|
|
|
@ -8,12 +8,12 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.prefab.UETab;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.machine.filter.BlockFilterable;
|
||||
import assemblyline.common.machine.imprinter.BlockImprintable;
|
||||
|
||||
/**
|
||||
* @author Briman0094
|
||||
*/
|
||||
public class BlockDetector extends BlockFilterable
|
||||
public class BlockDetector extends BlockImprintable
|
||||
{
|
||||
public BlockDetector(int blockID, int texture)
|
||||
{
|
||||
|
@ -53,23 +53,6 @@ public class BlockDetector extends BlockFilterable
|
|||
return this.blockIndexInTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityDetector)
|
||||
{
|
||||
((TileEntityDetector) tileEntity).toggleInversion();
|
||||
world.markBlockForRenderUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
|
||||
{
|
||||
|
|
|
@ -10,13 +10,12 @@ import net.minecraft.util.AxisAlignedBB;
|
|||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.machine.filter.ItemImprinter;
|
||||
import assemblyline.common.machine.filter.TileEntityFilterable;
|
||||
import assemblyline.common.machine.imprinter.ItemImprinter;
|
||||
import assemblyline.common.machine.imprinter.TileEntityImprintable;
|
||||
|
||||
public class TileEntityDetector extends TileEntityFilterable
|
||||
public class TileEntityDetector extends TileEntityImprintable
|
||||
{
|
||||
private boolean powering = false;
|
||||
private boolean isInverted = false;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
|
@ -40,9 +39,9 @@ public class TileEntityDetector extends TileEntityFilterable
|
|||
EntityItem e = (EntityItem) entities.get(i);
|
||||
ItemStack itemStack = e.func_92014_d();
|
||||
|
||||
boolean found = this.isFiltering(itemStack);
|
||||
powerCheck = this.isFiltering(itemStack);
|
||||
|
||||
if (this.isInverted)
|
||||
/*if (this.isInverted)
|
||||
{
|
||||
if (!found)
|
||||
{
|
||||
|
@ -57,7 +56,7 @@ public class TileEntityDetector extends TileEntityFilterable
|
|||
{
|
||||
powerCheck = true;
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -96,32 +95,11 @@ public class TileEntityDetector extends TileEntityFilterable
|
|||
super.invalidate();
|
||||
}
|
||||
|
||||
public boolean isInverted()
|
||||
{
|
||||
return this.isInverted;
|
||||
}
|
||||
|
||||
public void setInversion(boolean inverted)
|
||||
{
|
||||
this.isInverted = inverted;
|
||||
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
PacketManager.sendPacketToClients(this.getDescriptionPacket());
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleInversion()
|
||||
{
|
||||
this.setInversion(!this.isInverted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
|
||||
this.isInverted = tag.getBoolean("isInverted");
|
||||
this.powering = tag.getBoolean("powering");
|
||||
}
|
||||
|
||||
|
@ -130,7 +108,6 @@ public class TileEntityDetector extends TileEntityFilterable
|
|||
{
|
||||
super.writeToNBT(tag);
|
||||
|
||||
tag.setBoolean("isInverted", this.isInverted);
|
||||
tag.setBoolean("powering", this.powering);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.common.machine.filter;
|
||||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
@ -12,15 +12,16 @@ import net.minecraft.world.World;
|
|||
import universalelectricity.prefab.BlockMachine;
|
||||
import universalelectricity.prefab.implement.IRedstoneReceptor;
|
||||
import assemblyline.api.IFilterable;
|
||||
import assemblyline.common.machine.detector.TileEntityDetector;
|
||||
|
||||
/**
|
||||
* Extend this block class if a filter is allowed to be placed inside of this block.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
public abstract class BlockFilterable extends BlockMachine
|
||||
public abstract class BlockImprintable extends BlockMachine
|
||||
{
|
||||
public BlockFilterable(String name, int id, Material material, CreativeTabs creativeTab)
|
||||
public BlockImprintable(String name, int id, Material material, CreativeTabs creativeTab)
|
||||
{
|
||||
super(name, id, material, creativeTab);
|
||||
}
|
||||
|
@ -69,6 +70,23 @@ public abstract class BlockFilterable extends BlockMachine
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityImprintable)
|
||||
{
|
||||
((TileEntityImprintable) tileEntity).toggleInversion();
|
||||
world.markBlockForRenderUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.common.machine.filter;
|
||||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.common.machine.filter;
|
||||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -32,13 +32,13 @@ public class ContainerImprinter extends Container implements IInventory, ISlotWa
|
|||
this.inventoryPlayer = inventoryPlayer;
|
||||
|
||||
// Paper Input
|
||||
this.addSlotToContainer(new SlotFilter(this, 0, 42, 24));
|
||||
this.addSlotToContainer(new SlotImprint(this, 0, 42, 24));
|
||||
// Item Stamp
|
||||
this.addSlotToContainer(new Slot(this, 1, 78, 24));
|
||||
// Output Filter
|
||||
this.addSlotToContainer(new SlotFilterResult(this, 2, 136, 24));
|
||||
this.addSlotToContainer(new SlotImprintResult(this, 2, 136, 24));
|
||||
// Crafting Slot
|
||||
this.addSlotToContainer(new SlotFilter(this, 3, 78, 53));
|
||||
this.addSlotToContainer(new SlotImprint(this, 3, 78, 53));
|
||||
this.addSlotToContainer(new SlotCraftingResult(this, this, 4, 136, 53));
|
||||
|
||||
int var3;
|
|
@ -1,6 +1,6 @@
|
|||
package assemblyline.common.machine.filter;
|
||||
|
||||
public interface ISlotWatcher
|
||||
{
|
||||
public void slotContentsChanged();
|
||||
}
|
||||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
public interface ISlotWatcher
|
||||
{
|
||||
public void slotContentsChanged();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.common.machine.filter;
|
||||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.common.machine.filter;
|
||||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
|
@ -1,14 +1,14 @@
|
|||
package assemblyline.common.machine.filter;
|
||||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
|
||||
public class SlotFilter extends Slot
|
||||
public class SlotImprint extends Slot
|
||||
{
|
||||
|
||||
public SlotFilter(IInventory par1iInventory, int par2, int par3, int par4)
|
||||
public SlotImprint(IInventory par1iInventory, int par2, int par3, int par4)
|
||||
{
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package assemblyline.common.machine.filter;
|
||||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotFilterResult extends Slot
|
||||
public class SlotImprintResult extends Slot
|
||||
{
|
||||
|
||||
public SlotFilterResult(IInventory par1iInventory, int par2, int par3, int par4)
|
||||
public SlotImprintResult(IInventory par1iInventory, int par2, int par3, int par4)
|
||||
{
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.common.machine.filter;
|
||||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
|
@ -23,9 +23,13 @@ import assemblyline.common.machine.TileEntityAssemblyNetwork;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork implements IRotatable, IFilterable, IPacketReceiver, IInventory
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public abstract class TileEntityImprintable extends TileEntityAssemblyNetwork implements IRotatable, IFilterable, IPacketReceiver, IInventory
|
||||
{
|
||||
private ItemStack filterItem;
|
||||
private boolean inverted;
|
||||
|
||||
/**
|
||||
* Looks through the things in the filter and finds out which item is being filtered.
|
||||
|
@ -44,13 +48,13 @@ public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork imp
|
|||
{
|
||||
if (checkStacks.get(i) != null)
|
||||
{
|
||||
if (checkStacks.get(i).isItemEqual(itemStack)) { return true; }
|
||||
if (checkStacks.get(i).isItemEqual(itemStack)) { return !inverted; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -147,7 +151,11 @@ public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork imp
|
|||
public void setFilter(ItemStack filter)
|
||||
{
|
||||
this.setInventorySlotContents(0, filter);
|
||||
PacketManager.sendPacketToClients(this.getDescriptionPacket());
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||
{
|
||||
PacketManager.sendPacketToClients(this.getDescriptionPacket());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,6 +164,25 @@ public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork imp
|
|||
return this.getStackInSlot(0);
|
||||
}
|
||||
|
||||
public void setInverted(boolean inverted)
|
||||
{
|
||||
this.inverted = inverted;
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||
{
|
||||
PacketManager.sendPacketToClients(this.getDescriptionPacket());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInverted()
|
||||
{
|
||||
return this.inverted;
|
||||
}
|
||||
|
||||
public void toggleInversion()
|
||||
{
|
||||
setInverted(!isInverted());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getDirection()
|
||||
{
|
||||
|
@ -225,6 +252,7 @@ public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork imp
|
|||
if (getFilter() != null)
|
||||
getFilter().writeToNBT(filter);
|
||||
nbt.setTag("filter", filter);
|
||||
nbt.setBoolean("inverted", inverted);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -232,6 +260,7 @@ public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork imp
|
|||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
inverted = nbt.getBoolean("inverted");
|
||||
NBTTagCompound filter = nbt.getCompoundTag("filter");
|
||||
setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(filter));
|
||||
}
|
|
@ -1,25 +1,25 @@
|
|||
package assemblyline.common.machine.filter;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class WatchedSlot extends Slot
|
||||
{
|
||||
ISlotWatcher slotWatcher;
|
||||
|
||||
public WatchedSlot(IInventory inventory, int id, int xPosition, int yPosition, ISlotWatcher slotWatcher)
|
||||
{
|
||||
super(inventory, id, xPosition, yPosition);
|
||||
this.slotWatcher = slotWatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
if (slotWatcher != null)
|
||||
{
|
||||
slotWatcher.slotContentsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package assemblyline.common.machine.imprinter;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class WatchedSlot extends Slot
|
||||
{
|
||||
ISlotWatcher slotWatcher;
|
||||
|
||||
public WatchedSlot(IInventory inventory, int id, int xPosition, int yPosition, ISlotWatcher slotWatcher)
|
||||
{
|
||||
super(inventory, id, xPosition, yPosition);
|
||||
this.slotWatcher = slotWatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
if (slotWatcher != null)
|
||||
{
|
||||
slotWatcher.slotContentsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -6,11 +6,11 @@ import universalelectricity.core.UniversalElectricity;
|
|||
import universalelectricity.prefab.UETab;
|
||||
import assemblyline.client.render.BlockRenderingHandler;
|
||||
import assemblyline.common.machine.TileEntityRejector;
|
||||
import assemblyline.common.machine.filter.BlockFilterable;
|
||||
import assemblyline.common.machine.imprinter.BlockImprintable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockRejector extends BlockFilterable
|
||||
public class BlockRejector extends BlockImprintable
|
||||
{
|
||||
public BlockRejector(int id)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue