Manipulator now works
This commit is contained in:
parent
e6970bc083
commit
0f25136871
6 changed files with 30 additions and 76 deletions
|
@ -8,8 +8,9 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import resonantinduction.api.IFilterable;
|
||||
import resonantinduction.archaic.imprint.ItemBlockImprint;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
import calclavia.lib.prefab.tile.TileExternalInventory;
|
||||
|
||||
public abstract class TileEntityFilterable extends TileAssembly implements IRotatable, IFilterable
|
||||
public abstract class TileEntityFilterable extends TileExternalInventory implements IRotatable, IFilterable
|
||||
{
|
||||
private ItemStack filterItem;
|
||||
private boolean inverted;
|
||||
|
@ -18,18 +19,12 @@ public abstract class TileEntityFilterable extends TileAssembly implements IRota
|
|||
|
||||
public TileEntityFilterable()
|
||||
{
|
||||
super(0);
|
||||
this.maxSlots = 2;
|
||||
}
|
||||
|
||||
public TileEntityFilterable(long wattsPerTick, long maxEnergy)
|
||||
protected boolean isFunctioning()
|
||||
{
|
||||
super(wattsPerTick, maxEnergy);
|
||||
}
|
||||
|
||||
public TileEntityFilterable(long wattsPerTick)
|
||||
{
|
||||
super(wattsPerTick);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,10 +37,12 @@ public class BlockManipulator extends BlockImprintable
|
|||
|
||||
if (tileEntity instanceof TileManipulator)
|
||||
{
|
||||
((TileManipulator) tileEntity).setSelfPulse(!((TileManipulator) tileEntity).isSelfPulse());
|
||||
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText("Manip. set to " + (((TileManipulator) tileEntity).isSelfPulse() ? "auto pulse" : "not pulse")));
|
||||
if (!world.isRemote)
|
||||
{
|
||||
((TileManipulator) tileEntity).setSelfPulse(!((TileManipulator) tileEntity).isSelfPulse());
|
||||
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText("Manip. set to " + (((TileManipulator) tileEntity).isSelfPulse() ? "auto pulse" : "not pulse")));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -72,8 +74,10 @@ public class BlockManipulator extends BlockImprintable
|
|||
manip.toggleOutput();
|
||||
manip.toggleInversion();
|
||||
}
|
||||
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText("Manip. outputing = " + manip.isOutput()));
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText("Manip. outputing = " + manip.isOutput()));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -22,11 +22,6 @@ public class TileDetector extends TileEntityFilterable implements IPacketReceive
|
|||
{
|
||||
private boolean powering = false;
|
||||
|
||||
public TileDetector()
|
||||
{
|
||||
super(100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
|
@ -109,13 +104,12 @@ public class TileDetector extends TileEntityFilterable implements IPacketReceive
|
|||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, this.functioning, this.isInverted());
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, this.isInverted());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
this.functioning = data.readBoolean();
|
||||
this.setInverted(data.readBoolean());
|
||||
}
|
||||
|
||||
|
@ -128,11 +122,4 @@ public class TileDetector extends TileEntityFilterable implements IPacketReceive
|
|||
{
|
||||
return this.isPoweringTo(side) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return direction != this.getDirection();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,11 +31,6 @@ public class TileManipulator extends TileEntityFilterable implements IRotatable,
|
|||
/** The class that interacts with inventories for this machine */
|
||||
private InternalInventoryHandler invExtractionHelper;
|
||||
|
||||
public TileManipulator()
|
||||
{
|
||||
super(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
|
@ -83,7 +78,6 @@ public class TileManipulator extends TileEntityFilterable implements IRotatable,
|
|||
/** output location facing */
|
||||
Vector3 outputPosition = new Vector3(this);
|
||||
outputPosition.modifyPositionFromSide(this.getDirection().getOpposite());
|
||||
this.consumePower(1, true);
|
||||
|
||||
/** Prevents manipulators from spamming and duping items. */
|
||||
if (outputPosition.getTileEntity(this.worldObj) instanceof TileManipulator)
|
||||
|
@ -146,8 +140,6 @@ public class TileManipulator extends TileEntityFilterable implements IRotatable,
|
|||
/** output location facing */
|
||||
Vector3 outputPosition = new Vector3(this).modifyPositionFromSide(this.getDirection());
|
||||
|
||||
this.consumePower(1, true);
|
||||
|
||||
ItemStack itemStack = invHelper().tryGrabFromPosition(inputUp, ForgeDirection.UP, 1);
|
||||
|
||||
if (itemStack == null)
|
||||
|
@ -189,7 +181,7 @@ public class TileManipulator extends TileEntityFilterable implements IRotatable,
|
|||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, this.functioning, this.isInverted(), this.isSelfPulse(), this.isOutput());
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, this.isInverted(), this.isSelfPulse(), this.isOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -197,7 +189,6 @@ public class TileManipulator extends TileEntityFilterable implements IRotatable,
|
|||
{
|
||||
try
|
||||
{
|
||||
this.functioning = data.readBoolean();
|
||||
this.setInverted(data.readBoolean());
|
||||
this.setSelfPulse(data.readBoolean());
|
||||
this.setOutput(data.readBoolean());
|
||||
|
@ -208,12 +199,6 @@ public class TileManipulator extends TileEntityFilterable implements IRotatable,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection dir)
|
||||
{
|
||||
return dir != this.getDirection();
|
||||
}
|
||||
|
||||
public boolean isSelfPulse()
|
||||
{
|
||||
return selfPulse;
|
||||
|
@ -264,10 +249,4 @@ public class TileManipulator extends TileEntityFilterable implements IRotatable,
|
|||
{
|
||||
this.setOutput(!this.isOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExtraLoad()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -13,23 +14,18 @@ import resonantinduction.api.IBelt;
|
|||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.prefab.tile.TileEntityFilterable;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.network.IPacketReceiverWithID;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
/** @author Darkguardsman */
|
||||
public class TileRejector extends TileEntityFilterable
|
||||
public class TileRejector extends TileEntityFilterable implements IPacketReceiverWithID
|
||||
{
|
||||
|
||||
/** should the piston fire, or be extended */
|
||||
public boolean firePiston = false;
|
||||
|
||||
public TileRejector()
|
||||
{
|
||||
super(100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
|
@ -75,11 +71,10 @@ public class TileRejector extends TileEntityFilterable
|
|||
{
|
||||
this.firePiston = true;
|
||||
// TODO add config to adjust the motion magnitude per rejector
|
||||
entity.motionX = side.offsetX * 0.1;
|
||||
entity.motionY += 0.10000000298023224D;
|
||||
entity.motionZ = side.offsetZ * 0.1;
|
||||
this.consumePower(1, true);
|
||||
|
||||
entity.posX += side.offsetX;
|
||||
// entity.motionY += 0.10000000298023224D;
|
||||
entity.posZ += side.offsetZ;
|
||||
|
||||
if (!this.worldObj.isRemote && tileEntity instanceof IBelt)
|
||||
{
|
||||
((IBelt) tileEntity).ignoreEntity(entity);
|
||||
|
@ -101,30 +96,23 @@ public class TileRejector extends TileEntityFilterable
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection dir)
|
||||
{
|
||||
return dir != this.getDirection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, this.functioning, this.isInverted(), this.firePiston);
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, 0, this.isInverted(), this.firePiston);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean simplePacket(String id, ByteArrayDataInput dis, Player player)
|
||||
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.worldObj.isRemote && !super.simplePacket(id, dis, player))
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
if (id.equalsIgnoreCase("rejector"))
|
||||
if (id == 0)
|
||||
{
|
||||
this.functioning = dis.readBoolean();
|
||||
this.setInverted(dis.readBoolean());
|
||||
this.firePiston = dis.readBoolean();
|
||||
this.setInverted(data.readBoolean());
|
||||
this.firePiston = data.readBoolean();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +121,7 @@ public class TileRejector extends TileEntityFilterable
|
|||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import universalelectricity.api.net.IConnector;
|
|||
public interface IMechanicalConnector extends IMechanical, IConnector<IMechanicalNetwork>
|
||||
{
|
||||
/**
|
||||
* Uses this connector to send a packet to the client.
|
||||
* Uses this connector to send a packet to the client for the network.
|
||||
*
|
||||
* @return True if the packet was successfully sent.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue