Mo' work, removed charger & sorter for the moment
This commit is contained in:
parent
5f57391ed9
commit
41d5a0dc07
34 changed files with 446 additions and 1323 deletions
|
@ -1,5 +1,6 @@
|
||||||
package resonantinduction.archaic.filter.imprint;
|
package resonantinduction.archaic.filter.imprint;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -7,18 +8,17 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import resonant.api.IFilterable;
|
import resonant.api.IFilterable;
|
||||||
import resonant.lib.prefab.block.BlockRotatable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend this block class if a filter is allowed to be placed inside of this block.
|
* Extend this block class if a filter is allowed to be placed inside of this block.
|
||||||
*
|
*
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*/
|
*/
|
||||||
public abstract class BlockImprintable extends BlockRotatable
|
public abstract class BlockImprintable extends Block
|
||||||
{
|
{
|
||||||
public BlockImprintable(int id, Material material)
|
public BlockImprintable(Material material)
|
||||||
{
|
{
|
||||||
super(id, material);
|
super(material);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Allows filters to be placed inside of this block. */
|
/** Allows filters to be placed inside of this block. */
|
||||||
|
|
|
@ -16,5 +16,7 @@ object ResonantTab extends CreativeTabs(CreativeTabs.getNextID, "ResonantInducti
|
||||||
|
|
||||||
override def getTabIconItem: Item = itemStack.getItem
|
override def getTabIconItem: Item = itemStack.getItem
|
||||||
|
|
||||||
|
def itemStack(item: ItemStack) { itemStack = item}
|
||||||
|
|
||||||
def tab = this
|
def tab = this
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import codechicken.lib.render.uv.IconTransformation;
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -11,19 +12,15 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import universalelectricity.api.net.IConnector;
|
import universalelectricity.api.core.grid.INode;
|
||||||
import universalelectricity.api.net.INodeNetwork;
|
|
||||||
import universalelectricity.core.transform.vector.Vector3;
|
import universalelectricity.core.transform.vector.Vector3;
|
||||||
import universalelectricity.api.vector.VectorHelper;
|
|
||||||
import codechicken.lib.data.MCDataInput;
|
import codechicken.lib.data.MCDataInput;
|
||||||
import codechicken.lib.data.MCDataOutput;
|
import codechicken.lib.data.MCDataOutput;
|
||||||
import codechicken.lib.raytracer.IndexedCuboid6;
|
import codechicken.lib.raytracer.IndexedCuboid6;
|
||||||
import codechicken.lib.render.CCRenderState;
|
import codechicken.lib.render.CCRenderState;
|
||||||
import codechicken.lib.render.IconTransformation;
|
|
||||||
import codechicken.lib.render.RenderUtils;
|
import codechicken.lib.render.RenderUtils;
|
||||||
import codechicken.lib.vec.Cuboid6;
|
import codechicken.lib.vec.Cuboid6;
|
||||||
import codechicken.lib.vec.Translation;
|
import codechicken.lib.vec.Translation;
|
||||||
import codechicken.microblock.IHollowConnect;
|
|
||||||
import codechicken.multipart.JNormalOcclusion;
|
import codechicken.multipart.JNormalOcclusion;
|
||||||
import codechicken.multipart.NormalOcclusionTest;
|
import codechicken.multipart.NormalOcclusionTest;
|
||||||
import codechicken.multipart.PartMap;
|
import codechicken.multipart.PartMap;
|
||||||
|
@ -32,8 +29,9 @@ import codechicken.multipart.TSlottedPart;
|
||||||
import codechicken.multipart.TileMultipart;
|
import codechicken.multipart.TileMultipart;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import universalelectricity.core.transform.vector.VectorWorld;
|
||||||
|
|
||||||
public abstract class PartFramedConnection<M extends Enum, C extends IConnector<N>, N extends INodeNetwork> extends PartColorableMaterial<M> implements IConnector<N>, TSlottedPart, JNormalOcclusion, IHollowConnect
|
public abstract class PartFramedConnection<M extends Enum> extends PartColorableMaterial<M> implements TSlottedPart, JNormalOcclusion
|
||||||
{
|
{
|
||||||
public static IndexedCuboid6[] sides = new IndexedCuboid6[7];
|
public static IndexedCuboid6[] sides = new IndexedCuboid6[7];
|
||||||
public static IndexedCuboid6[] insulatedSides = new IndexedCuboid6[7];
|
public static IndexedCuboid6[] insulatedSides = new IndexedCuboid6[7];
|
||||||
|
@ -58,8 +56,6 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
||||||
|
|
||||||
protected Object[] connections = new Object[6];
|
protected Object[] connections = new Object[6];
|
||||||
|
|
||||||
protected N network;
|
|
||||||
|
|
||||||
/** Bitmask connections */
|
/** Bitmask connections */
|
||||||
public byte currentWireConnections = 0x00;
|
public byte currentWireConnections = 0x00;
|
||||||
public byte currentAcceptorConnections = 0x00;
|
public byte currentAcceptorConnections = 0x00;
|
||||||
|
@ -144,12 +140,6 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
||||||
return PartMap.CENTER.mask;
|
return PartMap.CENTER.mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHollowSize()
|
|
||||||
{
|
|
||||||
return isInsulated ? 8 : 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBlockedOnSide(ForgeDirection side)
|
public boolean isBlockedOnSide(ForgeDirection side)
|
||||||
{
|
{
|
||||||
TMultiPart blocker = tile().partMap(side.ordinal());
|
TMultiPart blocker = tile().partMap(side.ordinal());
|
||||||
|
@ -170,25 +160,10 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
||||||
return ((connections & tester) > 0);
|
return ((connections & tester) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bind(TileMultipart t)
|
|
||||||
{
|
|
||||||
if (this.getNetwork() != null)
|
|
||||||
{
|
|
||||||
getNetwork().getConnectors().remove(this);
|
|
||||||
super.bind(t);
|
|
||||||
getNetwork().getConnectors().add(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
super.bind(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** CONNECTION LOGIC CODE */
|
/** CONNECTION LOGIC CODE */
|
||||||
protected abstract boolean canConnectTo(TileEntity tile, ForgeDirection to);
|
protected abstract boolean canConnectTo(TileEntity tile, ForgeDirection to);
|
||||||
|
|
||||||
protected abstract C getConnector(TileEntity tile);
|
protected abstract INode getConnector(TileEntity tile);
|
||||||
|
|
||||||
public boolean canConnectBothSides(TileEntity tile, ForgeDirection side)
|
public boolean canConnectBothSides(TileEntity tile, ForgeDirection side)
|
||||||
{
|
{
|
||||||
|
@ -218,7 +193,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
||||||
|
|
||||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
TileEntity tileEntity = new VectorWorld(this.tile()).add(side).getTileEntity();
|
||||||
|
|
||||||
if (getConnector(tileEntity) != null && canConnectBothSides(tileEntity, side))
|
if (getConnector(tileEntity) != null && canConnectBothSides(tileEntity, side))
|
||||||
{
|
{
|
||||||
|
@ -235,7 +210,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
||||||
|
|
||||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
TileEntity tileEntity = new VectorWorld(this.tile()).add(side).getTileEntity();
|
||||||
|
|
||||||
if (canConnectTo(tileEntity, side) && canConnectBothSides(tileEntity, side))
|
if (canConnectTo(tileEntity, side) && canConnectBothSides(tileEntity, side))
|
||||||
{
|
{
|
||||||
|
@ -246,49 +221,6 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
||||||
return connections;
|
return connections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh()
|
|
||||||
{
|
|
||||||
if (!world().isRemote)
|
|
||||||
{
|
|
||||||
byte possibleWireConnections = getPossibleWireConnections();
|
|
||||||
byte possibleAcceptorConnections = getPossibleAcceptorConnections();
|
|
||||||
|
|
||||||
if (possibleWireConnections != this.currentWireConnections)
|
|
||||||
{
|
|
||||||
byte or = (byte) (possibleWireConnections | this.currentWireConnections);
|
|
||||||
|
|
||||||
// Connections have been removed
|
|
||||||
if (or != possibleWireConnections)
|
|
||||||
{
|
|
||||||
this.getNetwork().removeConnector(this);
|
|
||||||
this.getNetwork().split(this);
|
|
||||||
setNetwork(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
|
||||||
{
|
|
||||||
if (connectionMapContainsSide(possibleWireConnections, side))
|
|
||||||
{
|
|
||||||
TileEntity tileEntity = VectorHelper.getConnectorFromSide(world(), new Vector3(tile()), side, this);
|
|
||||||
|
|
||||||
if (getConnector(tileEntity) != null)
|
|
||||||
{
|
|
||||||
getNetwork().merge(getConnector(tileEntity).getNetwork());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentWireConnections = possibleWireConnections;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentAcceptorConnections = possibleAcceptorConnections;
|
|
||||||
this.getNetwork().reconstruct();
|
|
||||||
this.sendConnectionUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
tile().markRender();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Should include connections that are in the current connection maps even if those connections
|
/** Should include connections that are in the current connection maps even if those connections
|
||||||
* aren't allowed any more. This is so that networks split correctly. */
|
* aren't allowed any more. This is so that networks split correctly. */
|
||||||
@Override
|
@Override
|
||||||
|
@ -301,7 +233,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
||||||
for (byte i = 0; i < 6; i++)
|
for (byte i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
TileEntity tileEntity = new VectorWorld(this.tile()).add(side).getTileEntity();
|
||||||
|
|
||||||
if (isCurrentlyConnected(side))
|
if (isCurrentlyConnected(side))
|
||||||
{
|
{
|
||||||
|
@ -350,18 +282,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
||||||
@Override
|
@Override
|
||||||
public void onPartChanged(TMultiPart part)
|
public void onPartChanged(TMultiPart part)
|
||||||
{
|
{
|
||||||
refresh();
|
node.
|
||||||
}
|
|
||||||
|
|
||||||
public void copyFrom(PartFramedConnection<M, C, N> other)
|
|
||||||
{
|
|
||||||
this.isInsulated = other.isInsulated;
|
|
||||||
this.color = other.color;
|
|
||||||
this.connections = other.connections;
|
|
||||||
this.material = other.material;
|
|
||||||
this.currentWireConnections = other.currentWireConnections;
|
|
||||||
this.currentAcceptorConnections = other.currentAcceptorConnections;
|
|
||||||
this.setNetwork(other.getNetwork());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Packet Methods */
|
/** Packet Methods */
|
||||||
|
@ -407,19 +328,6 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Network Methods */
|
|
||||||
@Override
|
|
||||||
public void setNetwork(N network)
|
|
||||||
{
|
|
||||||
this.network = network;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IConnector<N> getInstance(ForgeDirection dir)
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import codechicken.lib.render.uv.IconTransformation;
|
||||||
import net.minecraft.client.particle.EffectRenderer;
|
import net.minecraft.client.particle.EffectRenderer;
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -12,18 +13,13 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import resonant.api.grid.INode;
|
|
||||||
import resonant.api.grid.INodeProvider;
|
|
||||||
import resonant.lib.grid.Node;
|
|
||||||
import codechicken.lib.data.MCDataInput;
|
import codechicken.lib.data.MCDataInput;
|
||||||
import codechicken.lib.data.MCDataOutput;
|
import codechicken.lib.data.MCDataOutput;
|
||||||
import codechicken.lib.raytracer.IndexedCuboid6;
|
import codechicken.lib.raytracer.IndexedCuboid6;
|
||||||
import codechicken.lib.render.CCRenderState;
|
import codechicken.lib.render.CCRenderState;
|
||||||
import codechicken.lib.render.IconTransformation;
|
|
||||||
import codechicken.lib.render.RenderUtils;
|
import codechicken.lib.render.RenderUtils;
|
||||||
import codechicken.lib.vec.Cuboid6;
|
import codechicken.lib.vec.Cuboid6;
|
||||||
import codechicken.lib.vec.Translation;
|
import codechicken.lib.vec.Translation;
|
||||||
import codechicken.microblock.IHollowConnect;
|
|
||||||
import codechicken.multipart.IconHitEffects;
|
import codechicken.multipart.IconHitEffects;
|
||||||
import codechicken.multipart.JIconHitEffects;
|
import codechicken.multipart.JIconHitEffects;
|
||||||
import codechicken.multipart.JNormalOcclusion;
|
import codechicken.multipart.JNormalOcclusion;
|
||||||
|
@ -34,6 +30,9 @@ import codechicken.multipart.TSlottedPart;
|
||||||
import codechicken.multipart.TileMultipart;
|
import codechicken.multipart.TileMultipart;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import universalelectricity.api.core.grid.INode;
|
||||||
|
import universalelectricity.api.core.grid.INodeProvider;
|
||||||
|
import universalelectricity.core.grid.Node;
|
||||||
|
|
||||||
public abstract class PartFramedNode<M extends Enum, N extends Node, T extends INodeProvider> extends PartColorableMaterial<M> implements INodeProvider, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
|
public abstract class PartFramedNode<M extends Enum, N extends Node, T extends INodeProvider> extends PartColorableMaterial<M> implements INodeProvider, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,190 @@
|
||||||
|
package resonantinduction.core.prefab.part
|
||||||
|
|
||||||
|
import java.util.{Collection, HashSet, Set}
|
||||||
|
|
||||||
|
import codechicken.lib.data.{MCDataInput, MCDataOutput}
|
||||||
|
import codechicken.lib.raytracer.IndexedCuboid6
|
||||||
|
import codechicken.lib.vec.Cuboid6
|
||||||
|
import codechicken.multipart.{IconHitEffects, JIconHitEffects, JNormalOcclusion, NormalOcclusionTest, PartMap, TMultiPart, TSlottedPart, TileMultipart}
|
||||||
|
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||||
|
import net.minecraft.client.particle.EffectRenderer
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
|
import net.minecraft.item.Item
|
||||||
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
|
import net.minecraft.util.{IIcon, MovingObjectPosition}
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection
|
||||||
|
import universalelectricity.api.core.grid.{INode, INodeProvider}
|
||||||
|
|
||||||
|
object PartFramedNode {
|
||||||
|
def connectionMapContainsSide(connections: Byte, side: ForgeDirection): Boolean = {
|
||||||
|
val tester: Byte = (1 << side.ordinal).asInstanceOf[Byte]
|
||||||
|
return ((connections & tester) > 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
var sides: Array[IndexedCuboid6] = new Array[IndexedCuboid6](7)
|
||||||
|
var insulatedSides: Array[IndexedCuboid6] = new Array[IndexedCuboid6](7)
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class PartFramedNode[M](insulationType: Item) extends PartColorableMaterial[M](insulationType: Item) with INodeProvider with TSlottedPart with JNormalOcclusion with JIconHitEffects {
|
||||||
|
|
||||||
|
protected var connections: Array[AnyRef] = new Array[AnyRef](6)
|
||||||
|
protected var node: INode
|
||||||
|
/** Bitmask connections */
|
||||||
|
var currentConnections: Byte = 0x00
|
||||||
|
/** Client Side */
|
||||||
|
private var testingSide: ForgeDirection = null
|
||||||
|
@SideOnly(Side.CLIENT) protected var breakIcon: IIcon = null
|
||||||
|
|
||||||
|
def preparePlacement(meta: Int) {
|
||||||
|
this.setMaterial(meta)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def occlusionTest(other: TMultiPart): Boolean = {
|
||||||
|
return NormalOcclusionTest.apply(this, other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def getSubParts: Iterable[IndexedCuboid6] = {
|
||||||
|
val currentSides: Array[IndexedCuboid6] = if (isInsulated) PartFramedNode.insulatedSides.clone() else PartFramedNode.sides.clone()
|
||||||
|
if (tile != null) {
|
||||||
|
for (side <- ForgeDirection.VALID_DIRECTIONS) {
|
||||||
|
val ord: Int = side.ordinal
|
||||||
|
if (PartFramedNode.connectionMapContainsSide(getAllCurrentConnections, side) || side == testingSide) currentSides(ord) = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return currentSides
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Rendering and block bounds. */
|
||||||
|
override def getCollisionBoxes: Iterable[Cuboid6] = {
|
||||||
|
val collisionBoxes: Set[Cuboid6] = new HashSet[Cuboid6]
|
||||||
|
collisionBoxes.addAll(getSubParts.asInstanceOf[Collection[_ <: Cuboid6]])
|
||||||
|
return collisionBoxes.toArray().asInstanceOf[Array[Cuboid6]];
|
||||||
|
}
|
||||||
|
|
||||||
|
override def getStrength(hit: MovingObjectPosition, player: EntityPlayer): Float = {
|
||||||
|
return 10F
|
||||||
|
}
|
||||||
|
|
||||||
|
def getBounds: Cuboid6 = {
|
||||||
|
return new Cuboid6(0.375, 0.375, 0.375, 0.625, 0.625, 0.625)
|
||||||
|
}
|
||||||
|
|
||||||
|
def getBreakingIcon(subPart: AnyRef, side: Int): IIcon = {
|
||||||
|
return breakIcon
|
||||||
|
}
|
||||||
|
|
||||||
|
def getBrokenIcon(side: Int): IIcon = {
|
||||||
|
return breakIcon
|
||||||
|
}
|
||||||
|
|
||||||
|
def getOcclusionBoxes: Iterable[Cuboid6] = {
|
||||||
|
return getCollisionBoxes
|
||||||
|
}
|
||||||
|
|
||||||
|
def getSlotMask: Int = {
|
||||||
|
return PartMap.CENTER.mask
|
||||||
|
}
|
||||||
|
|
||||||
|
def getHollowSize: Int = {
|
||||||
|
return if (isInsulated) 8 else 6
|
||||||
|
}
|
||||||
|
|
||||||
|
override def addHitEffects(hit: MovingObjectPosition, effectRenderer: EffectRenderer) {
|
||||||
|
IconHitEffects.addHitEffects(this, hit, effectRenderer)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def addDestroyEffects(effectRenderer: EffectRenderer) {
|
||||||
|
IconHitEffects.addDestroyEffects(this, effectRenderer, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
def isBlockedOnSide(side: ForgeDirection): Boolean = {
|
||||||
|
val blocker: TMultiPart = tile.partMap(side.ordinal)
|
||||||
|
testingSide = side
|
||||||
|
val expandable: Boolean = NormalOcclusionTest.apply(this, blocker)
|
||||||
|
testingSide = null
|
||||||
|
return !expandable
|
||||||
|
}
|
||||||
|
|
||||||
|
def getAllCurrentConnections: Byte = {
|
||||||
|
return (currentConnections)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def bind(t: TileMultipart) {
|
||||||
|
node.deconstruct
|
||||||
|
super.bind(t)
|
||||||
|
node.reconstruct
|
||||||
|
}
|
||||||
|
|
||||||
|
def isCurrentlyConnected(side: ForgeDirection): Boolean = {
|
||||||
|
return PartFramedNode.connectionMapContainsSide(getAllCurrentConnections, side)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def onWorldJoin {
|
||||||
|
node.reconstruct
|
||||||
|
}
|
||||||
|
|
||||||
|
override def onNeighborChanged {
|
||||||
|
node.reconstruct
|
||||||
|
}
|
||||||
|
|
||||||
|
override def onWorldSeparate {
|
||||||
|
node.deconstruct
|
||||||
|
}
|
||||||
|
|
||||||
|
def copyFrom(other: PartFramedNode[M]) {
|
||||||
|
this.isInsulated = other.isInsulated
|
||||||
|
this.color = other.color
|
||||||
|
this.connections = other.connections
|
||||||
|
this.material = other.material
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Packet Methods */
|
||||||
|
def sendConnectionUpdate {
|
||||||
|
tile.getWriteStream(this).writeByte(0).writeByte(currentConnections)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def readDesc(packet: MCDataInput) {
|
||||||
|
super.readDesc(packet)
|
||||||
|
currentConnections = packet.readByte
|
||||||
|
}
|
||||||
|
|
||||||
|
override def writeDesc(packet: MCDataOutput) {
|
||||||
|
super.writeDesc(packet)
|
||||||
|
packet.writeByte(currentConnections)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def read(packet: MCDataInput) {
|
||||||
|
read(packet, packet.readUByte)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def read(packet: MCDataInput, packetID: Int) {
|
||||||
|
if (packetID == 0) {
|
||||||
|
currentConnections = packet.readByte
|
||||||
|
tile.markRender
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
super.read(packet, packetID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings(Array("hiding")) def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode = {
|
||||||
|
if (node != null && nodeType != null) {
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override def save(nbt: NBTTagCompound) {
|
||||||
|
super.save(nbt)
|
||||||
|
node.save(nbt)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def load(nbt: NBTTagCompound) {
|
||||||
|
super.load(nbt)
|
||||||
|
node.load(nbt)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def toString: String = {
|
||||||
|
return this.getClass.getSimpleName + this.hashCode
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,200 +0,0 @@
|
||||||
package resonantinduction.core.prefab.part;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
import resonant.api.IExternalInventory;
|
|
||||||
import resonant.api.IExternalInventoryBox;
|
|
||||||
import resonant.lib.utility.inventory.ExternalInventory;
|
|
||||||
import codechicken.lib.data.MCDataInput;
|
|
||||||
import codechicken.lib.data.MCDataOutput;
|
|
||||||
|
|
||||||
/** Panel based part that provides a prefab for other tiles to build an inventory from. Inventory
|
|
||||||
* code is wrapped to an ExternalInventory object allowing inventories to be implemented without
|
|
||||||
* repeat copying of code. As well Code is based on TileInventory and should operate in the exact
|
|
||||||
* same way.
|
|
||||||
*
|
|
||||||
* @author Darkguardsman */
|
|
||||||
public abstract class PartInventoryPanel extends PartFace implements IExternalInventory, ISidedInventory
|
|
||||||
{
|
|
||||||
protected IExternalInventoryBox inventory;
|
|
||||||
protected int maxSlots = 1;
|
|
||||||
protected boolean markedForUpdate = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update()
|
|
||||||
{
|
|
||||||
super.update();
|
|
||||||
if (ticks % 3 == 0 && !world().isRemote && markedForUpdate)
|
|
||||||
{
|
|
||||||
sendDescUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInventoryChanged()
|
|
||||||
{
|
|
||||||
markedForUpdate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Save and load */
|
|
||||||
@Override
|
|
||||||
public void load(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.load(nbt);
|
|
||||||
this.getInventory().load(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.save(nbt);
|
|
||||||
this.getInventory().save(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readDesc(MCDataInput packet)
|
|
||||||
{
|
|
||||||
super.readDesc(packet);
|
|
||||||
getInventory().load(packet.readNBTTagCompound());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeDesc(MCDataOutput packet)
|
|
||||||
{
|
|
||||||
super.writeDesc(packet);
|
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
|
||||||
getInventory().save(nbt);
|
|
||||||
packet.writeNBTTagCompound(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IExternalInventoryBox getInventory()
|
|
||||||
{
|
|
||||||
if (inventory == null)
|
|
||||||
{
|
|
||||||
inventory = new ExternalInventory(null, this, this.maxSlots);
|
|
||||||
}
|
|
||||||
|
|
||||||
return inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSizeInventory()
|
|
||||||
{
|
|
||||||
return this.getInventory().getSizeInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlot(int i)
|
|
||||||
{
|
|
||||||
return this.getInventory().getStackInSlot(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack decrStackSize(int i, int j)
|
|
||||||
{
|
|
||||||
return this.getInventory().decrStackSize(i, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrStackSize(int slot, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
if (this.getStackInSlot(slot) == null)
|
|
||||||
{
|
|
||||||
setInventorySlotContents(slot, itemStack.copy());
|
|
||||||
}
|
|
||||||
else if (this.getStackInSlot(slot).isItemEqual(itemStack))
|
|
||||||
{
|
|
||||||
getStackInSlot(slot).stackSize += itemStack.stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
onInventoryChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlotOnClosing(int i)
|
|
||||||
{
|
|
||||||
return this.getInventory().getStackInSlotOnClosing(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
|
||||||
{
|
|
||||||
this.getInventory().setInventorySlotContents(i, itemstack);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInvName()
|
|
||||||
{
|
|
||||||
return "Inventory";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInvNameLocalized()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventoryStackLimit()
|
|
||||||
{
|
|
||||||
return this.getInventory().getInventoryStackLimit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
|
||||||
{
|
|
||||||
return this.getInventory().isUseableByPlayer(entityplayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openChest()
|
|
||||||
{
|
|
||||||
this.getInventory().openChest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void closeChest()
|
|
||||||
{
|
|
||||||
this.getInventory().closeChest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
|
||||||
{
|
|
||||||
return this.getInventory().isItemValidForSlot(i, itemstack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int[] getAccessibleSlotsFromSide(int var1)
|
|
||||||
{
|
|
||||||
return this.getInventory().getAccessibleSlotsFromSide(var1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInsertItem(int i, ItemStack itemstack, int j)
|
|
||||||
{
|
|
||||||
return this.getInventory().canInsertItem(i, itemstack, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtractItem(int i, ItemStack itemstack, int j)
|
|
||||||
{
|
|
||||||
return this.getInventory().canExtractItem(i, itemstack, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canRemove(ItemStack stack, int slot, ForgeDirection side)
|
|
||||||
{
|
|
||||||
return slot < this.getSizeInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,11 +3,10 @@ package resonantinduction.electrical.battery;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import resonant.lib.prefab.tile.TileElectrical;
|
|
||||||
import universalelectricity.api.net.IConnector;
|
|
||||||
import universalelectricity.core.transform.vector.Vector3;
|
import universalelectricity.core.transform.vector.Vector3;
|
||||||
|
import resonant.lib.content.prefab.java.TileElectric;
|
||||||
|
|
||||||
public class TileEnergyDistribution extends TileElectrical implements IConnector<EnergyDistributionNetwork>
|
public class TileEnergyDistribution extends TileElectric
|
||||||
{
|
{
|
||||||
public boolean markClientUpdate = false;
|
public boolean markClientUpdate = false;
|
||||||
public boolean markDistributionUpdate = false;
|
public boolean markDistributionUpdate = false;
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
package resonantinduction.electrical.charger;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import resonantinduction.core.prefab.part.IHighlight;
|
|
||||||
import codechicken.lib.vec.BlockCoord;
|
|
||||||
import codechicken.lib.vec.Vector3;
|
|
||||||
import codechicken.microblock.FacePlacementGrid$;
|
|
||||||
import codechicken.multipart.JItemMultiPart;
|
|
||||||
import codechicken.multipart.MultiPartRegistry;
|
|
||||||
import codechicken.multipart.TMultiPart;
|
|
||||||
|
|
||||||
public class ItemCharger extends JItemMultiPart implements IHighlight
|
|
||||||
{
|
|
||||||
public ItemCharger(int id)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
|
|
||||||
{
|
|
||||||
side = FacePlacementGrid$.MODULE$.getHitSlot(hit, side);
|
|
||||||
PartCharger part = (PartCharger) MultiPartRegistry.createPart("resonant_induction_charger", false);
|
|
||||||
|
|
||||||
if (part != null)
|
|
||||||
{
|
|
||||||
int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
|
||||||
int facing = l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
|
|
||||||
part.preparePlacement(side, facing);
|
|
||||||
}
|
|
||||||
|
|
||||||
return part;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHighlightType()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,149 +0,0 @@
|
||||||
package resonantinduction.electrical.charger;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
import resonant.lib.utility.WrenchUtility;
|
|
||||||
import resonant.lib.utility.inventory.InventoryUtility;
|
|
||||||
import resonantinduction.core.prefab.part.PartInventoryPanel;
|
|
||||||
import resonantinduction.electrical.Electrical;
|
|
||||||
import universalelectricity.api.CompatibilityModule;
|
|
||||||
import universalelectricity.api.UniversalClass;
|
|
||||||
import universalelectricity.api.energy.IEnergyInterface;
|
|
||||||
import codechicken.lib.vec.Vector3;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/** Micro part machine designed to charge all items contained inside of it. Doesn't contain its own
|
|
||||||
* battery and only acts as an inventory. Items are charged each time doReceive is called by an
|
|
||||||
* energy supplier.
|
|
||||||
*
|
|
||||||
* @author Darkguardsman, converted to Part by Calclavia */
|
|
||||||
@UniversalClass
|
|
||||||
public class PartCharger extends PartInventoryPanel implements IEnergyInterface
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
|
|
||||||
{
|
|
||||||
if (WrenchUtility.isUsableWrench(player, player.inventory.getCurrentItem(), x(), y(), z()))
|
|
||||||
{
|
|
||||||
if (!world().isRemote)
|
|
||||||
{
|
|
||||||
WrenchUtility.damageWrench(player, player.inventory.getCurrentItem(), x(), y(), z());
|
|
||||||
facing = (byte) ((facing + 1) % 4);
|
|
||||||
sendDescUpdate();
|
|
||||||
tile().notifyPartChange(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
if (getStackInSlot(0) == null && item != null && CompatibilityModule.isHandler(item.getItem()))
|
|
||||||
{
|
|
||||||
setInventorySlotContents(0, item);
|
|
||||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
|
||||||
|
|
||||||
if (!world().isRemote)
|
|
||||||
sendDescUpdate();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getStackInSlot(0) != null)
|
|
||||||
{
|
|
||||||
InventoryUtility.dropItemStack(world(), new universalelectricity.core.transform.vector.Vector3(player), getStackInSlot(0), 0);
|
|
||||||
setInventorySlotContents(0, null);
|
|
||||||
if (!world().isRemote)
|
|
||||||
sendDescUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
|
||||||
{
|
|
||||||
return obj instanceof IEnergyInterface && placementSide != direction.getOpposite();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
|
||||||
{
|
|
||||||
if (receive > 0)
|
|
||||||
{
|
|
||||||
long energyUsed = 0;
|
|
||||||
for (int slot = 0; slot < this.getSizeInventory(); slot++)
|
|
||||||
{
|
|
||||||
energyUsed += CompatibilityModule.chargeItem(this.getStackInSlot(slot), receive - energyUsed, doReceive);
|
|
||||||
if (energyUsed >= receive)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (energyUsed > 0)
|
|
||||||
this.markedForUpdate = true;
|
|
||||||
|
|
||||||
return energyUsed;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void renderDynamic(Vector3 pos, float frame, int pass)
|
|
||||||
{
|
|
||||||
if (pass == 0)
|
|
||||||
{
|
|
||||||
RenderCharger.INSTANCE.render(this, pos.x, pos.y, pos.z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ItemStack getItem()
|
|
||||||
{
|
|
||||||
return new ItemStack(Electrical.itemCharger);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getType()
|
|
||||||
{
|
|
||||||
return "resonant_induction_charger";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<ItemStack> getDrops()
|
|
||||||
{
|
|
||||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
|
||||||
drops.add(getItem());
|
|
||||||
|
|
||||||
for (int i = 0; i < getSizeInventory(); i++)
|
|
||||||
if (getStackInSlot(i) != null)
|
|
||||||
drops.add(getStackInSlot(i));
|
|
||||||
|
|
||||||
return drops;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
|
||||||
{
|
|
||||||
return slot < this.getSizeInventory() && stack != null && CompatibilityModule.isHandler(stack.getItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "[PartCharger]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s ";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,91 +0,0 @@
|
||||||
package resonantinduction.electrical.charger;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
|
||||||
import net.minecraftforge.client.model.IModelCustom;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import resonant.api.items.ISimpleItemRenderer;
|
|
||||||
import resonant.lib.render.RenderItemOverlayUtility;
|
|
||||||
import resonant.lib.render.RenderUtility;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import universalelectricity.api.CompatibilityModule;
|
|
||||||
import universalelectricity.api.energy.UnitDisplay;
|
|
||||||
import universalelectricity.api.energy.UnitDisplay.Unit;
|
|
||||||
import universalelectricity.core.transform.vector.Vector3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renderer for electric item charger
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class RenderCharger implements ISimpleItemRenderer
|
|
||||||
{
|
|
||||||
public static final RenderCharger INSTANCE = new RenderCharger();
|
|
||||||
|
|
||||||
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "charger.tcn");
|
|
||||||
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "charger.png");
|
|
||||||
|
|
||||||
public void render(PartCharger part, double x, double y, double z)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
|
|
||||||
|
|
||||||
RenderUtility.rotateFaceToSideNoTranslate(part.placementSide);
|
|
||||||
RenderUtility.rotateBlockBasedOnDirection(part.getFacing());
|
|
||||||
|
|
||||||
RenderUtility.bind(TEXTURE);
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef(0, 0.12f, 0);
|
|
||||||
MODEL.renderAll();
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
|
||||||
if (part.getStackInSlot(0) != null)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
|
|
||||||
RenderUtility.rotateFaceToSideNoTranslate(part.placementSide);
|
|
||||||
RenderUtility.rotateBlockBasedOnDirection(part.getFacing());
|
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
|
||||||
RenderItemOverlayUtility.renderItem(part.world(), part.placementSide, part.getStackInSlot(0), new Vector3(0.00, -0.3, -0.00), 0, 4);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
|
||||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
|
||||||
boolean isLooking = false;
|
|
||||||
|
|
||||||
MovingObjectPosition objectPosition = player.rayTrace(8, 1);
|
|
||||||
|
|
||||||
if (objectPosition != null)
|
|
||||||
{
|
|
||||||
if (objectPosition.blockX == part.x() && objectPosition.blockY == part.y() && objectPosition.blockZ == part.z())
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Render item and tool tip
|
|
||||||
*/
|
|
||||||
if (CompatibilityModule.getMaxEnergyItem(part.getStackInSlot(0)) > 0)
|
|
||||||
{
|
|
||||||
long energy = CompatibilityModule.getEnergyItem(part.getStackInSlot(0));
|
|
||||||
long maxEnergy = CompatibilityModule.getMaxEnergyItem(part.getStackInSlot(0));
|
|
||||||
RenderUtility.renderFloatingText(UnitDisplay.getDisplay(energy, Unit.JOULES, 2, true) + "/" + UnitDisplay.getDisplay(maxEnergy, Unit.JOULES, 2, true), new Vector3((float) x + 0.5F, (float) y + 0.8F, (float) z + 0.5F));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderInventoryItem(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
GL11.glTranslatef(0f, 0.5f, 0f);
|
|
||||||
RenderUtility.bind(TEXTURE);
|
|
||||||
MODEL.renderAll();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package resonantinduction.electrical.distributor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @since 25/03/14
|
|
||||||
* @author tgame14
|
|
||||||
*/
|
|
||||||
public enum EnumDistributorMode
|
|
||||||
{
|
|
||||||
PULL, PUSH
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
package resonantinduction.electrical.distributor
|
|
||||||
|
|
||||||
import java.util
|
|
||||||
import java.util.Collections
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material
|
|
||||||
import net.minecraft.inventory.IInventory
|
|
||||||
import net.minecraft.item.ItemStack
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection
|
|
||||||
import resonant.content.spatial.block.SpatialTile
|
|
||||||
import resonant.lib.content.prefab.{TElectric, TInventory}
|
|
||||||
import resonant.lib.utility.inventory.InventoryUtility
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Block that interacts with connected inventories
|
|
||||||
*
|
|
||||||
* @since 22/03/14
|
|
||||||
* @author tgame14
|
|
||||||
*/
|
|
||||||
class TileDistributor extends SpatialTile(Material.rock) with TInventory with TElectric
|
|
||||||
{
|
|
||||||
var state: EnumDistributorMode = EnumDistributorMode.PUSH
|
|
||||||
var targetNode = position
|
|
||||||
|
|
||||||
override def getSizeInventory = 0
|
|
||||||
|
|
||||||
override def update(): Unit =
|
|
||||||
{
|
|
||||||
super.update()
|
|
||||||
val prevNode = targetNode.clone()
|
|
||||||
|
|
||||||
val shuffledDirs = util.Arrays.asList(ForgeDirection.VALID_DIRECTIONS)
|
|
||||||
Collections.shuffle(shuffledDirs)
|
|
||||||
|
|
||||||
val hasInventoriesAround = (0 until shuffledDirs.toArray().size) map (i => (prevNode + ForgeDirection.getOrientation(i)).getTileEntity) exists (_.isInstanceOf[IInventory])
|
|
||||||
|
|
||||||
if (!targetNode.equals(prevNode) && hasInventoriesAround)
|
|
||||||
{
|
|
||||||
val inv: IInventory = targetNode.getTileEntity(world).asInstanceOf[IInventory]
|
|
||||||
callAction(inv)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
targetNode = position
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected def callAction(inv: IInventory)
|
|
||||||
{
|
|
||||||
state match
|
|
||||||
{
|
|
||||||
case EnumDistributorMode.PUSH =>
|
|
||||||
{
|
|
||||||
InventoryUtility.putStackInInventory(inv, getStackInSlot(0), false)
|
|
||||||
}
|
|
||||||
|
|
||||||
case EnumDistributorMode.PULL =>
|
|
||||||
{
|
|
||||||
val filterStack: ItemStack = getStackInSlot(1)
|
|
||||||
if (filterStack == null)
|
|
||||||
{
|
|
||||||
InventoryUtility.putStackInInventory(this, InventoryUtility.takeTopItemFromInventory(inv, ForgeDirection.UP.ordinal()), false)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var index = 0
|
|
||||||
while (index < inv.getSizeInventory)
|
|
||||||
{
|
|
||||||
if (inv.getStackInSlot(index) != null && inv.getStackInSlot(index).isItemEqual(filterStack))
|
|
||||||
{
|
|
||||||
var removeAmount = 0
|
|
||||||
|
|
||||||
if (getStackInSlot(0) != null && getStackInSlot(0).isItemEqual(filterStack))
|
|
||||||
{
|
|
||||||
removeAmount = getStackInSlot(0).getItem.getItemStackLimit - getStackInSlot(0).stackSize
|
|
||||||
}
|
|
||||||
|
|
||||||
inv.getStackInSlot(index).stackSize -= removeAmount
|
|
||||||
InventoryUtility.putStackInInventory(this, inv.getStackInSlot(index), false)
|
|
||||||
}
|
|
||||||
index += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
@ -21,8 +22,6 @@ import resonantinduction.electrical.wire.flat.PartFlatWire;
|
||||||
import resonantinduction.electrical.wire.flat.RenderFlatWire;
|
import resonantinduction.electrical.wire.flat.RenderFlatWire;
|
||||||
import resonantinduction.electrical.wire.framed.PartFramedWire;
|
import resonantinduction.electrical.wire.framed.PartFramedWire;
|
||||||
import resonantinduction.electrical.wire.framed.RenderFramedWire;
|
import resonantinduction.electrical.wire.framed.RenderFramedWire;
|
||||||
import universalelectricity.api.energy.UnitDisplay;
|
|
||||||
import universalelectricity.api.energy.UnitDisplay.Unit;
|
|
||||||
import codechicken.lib.vec.BlockCoord;
|
import codechicken.lib.vec.BlockCoord;
|
||||||
import codechicken.lib.vec.Vector3;
|
import codechicken.lib.vec.Vector3;
|
||||||
import codechicken.multipart.ControlKeyModifer;
|
import codechicken.multipart.ControlKeyModifer;
|
||||||
|
@ -31,15 +30,16 @@ import codechicken.multipart.MultiPartRegistry;
|
||||||
import codechicken.multipart.TMultiPart;
|
import codechicken.multipart.TMultiPart;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import universalelectricity.api.UnitDisplay;
|
||||||
|
|
||||||
public class ItemWire extends JItemMultiPart
|
public class ItemWire extends JItemMultiPart
|
||||||
{
|
{
|
||||||
public ItemWire(int id)
|
public ItemWire()
|
||||||
{
|
{
|
||||||
super(id);
|
super();
|
||||||
this.setUnlocalizedName(Reference.PREFIX + "wire");
|
this.setUnlocalizedName(Reference.prefix() + "wire");
|
||||||
this.setTextureName(Reference.PREFIX + "wire");
|
this.setTextureName(Reference.prefix() + "wire");
|
||||||
this.setCreativeTab(ResonantTab.DEFAULT);
|
this.setCreativeTab(ResonantTab.tab());
|
||||||
this.setHasSubtypes(true);
|
this.setHasSubtypes(true);
|
||||||
this.setMaxDamage(0);
|
this.setMaxDamage(0);
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,8 @@ public class ItemWire extends JItemMultiPart
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.resistance").replace("%v", "" + EnumColor.ORANGE + UnitDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].resistance, Unit.RESISTANCE)));
|
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.resistance").replace("%v", "" + EnumColor.ORANGE + new UnitDisplay(UnitDisplay.Unit.RESISTANCE, EnumWireMaterial.values()[itemstack.getItemDamage()].resistance)));
|
||||||
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.current").replace("%v", "" + EnumColor.ORANGE + UnitDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].maxAmps, Unit.AMPERE)));
|
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.current").replace("%v", "" + EnumColor.ORANGE + new UnitDisplay(UnitDisplay.Unit.AMPERE, EnumWireMaterial.values()[itemstack.getItemDamage()].maxAmps)));
|
||||||
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.damage").replace("%v", "" + EnumColor.ORANGE + EnumWireMaterial.values()[itemstack.getItemDamage()].damage));
|
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.damage").replace("%v", "" + EnumColor.ORANGE + EnumWireMaterial.values()[itemstack.getItemDamage()].damage));
|
||||||
list.addAll(LanguageUtility.splitStringPerWord(LanguageUtility.getLocal("tooltip.wire.helpText"), 5));
|
list.addAll(LanguageUtility.splitStringPerWord(LanguageUtility.getLocal("tooltip.wire.helpText"), 5));
|
||||||
}
|
}
|
||||||
|
@ -118,9 +118,9 @@ public class ItemWire extends JItemMultiPart
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerIcons(IIconRegister register)
|
public void registerIcons(IIconRegister register)
|
||||||
{
|
{
|
||||||
RenderFlatWire.flatWireTexture = register.registerIcon(Reference.PREFIX + "models/flatWire");
|
RenderFlatWire.flatWireTexture = register.registerIcon(Reference.prefix() + "models/flatWire");
|
||||||
RenderFramedWire.wireIcon = register.registerIcon(Reference.PREFIX + "models/wire");
|
RenderFramedWire.wireIcon = register.registerIcon(Reference.prefix() + "models/wire");
|
||||||
RenderFramedWire.insulationIcon = register.registerIcon(Reference.PREFIX + "models/insulation");
|
RenderFramedWire.insulationIcon = register.registerIcon(Reference.prefix() + "models/insulation");
|
||||||
super.registerIcons(register);
|
super.registerIcons(register);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ public class ItemWire extends JItemMultiPart
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
|
public void getSubItems(Item itemID, CreativeTabs tab, List listToAddTo)
|
||||||
{
|
{
|
||||||
for (EnumWireMaterial mat : EnumWireMaterial.values())
|
for (EnumWireMaterial mat : EnumWireMaterial.values())
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockColored;
|
import net.minecraft.block.BlockColored;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemShears;
|
import net.minecraft.item.ItemShears;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -32,7 +33,7 @@ public abstract class PartAdvancedWire extends PartConductor
|
||||||
|
|
||||||
public EnumWireMaterial material = EnumWireMaterial.COPPER;
|
public EnumWireMaterial material = EnumWireMaterial.COPPER;
|
||||||
public boolean isInsulated = false;
|
public boolean isInsulated = false;
|
||||||
protected ItemStack insulationType = new ItemStack(Block.cloth);
|
protected ItemStack insulationType = new ItemStack(Blocks.wool);
|
||||||
|
|
||||||
/** INTERNAL USE. Can this conductor connect with an external object? */
|
/** INTERNAL USE. Can this conductor connect with an external object? */
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,11 +6,4 @@ import resonantinduction.mechanical.gearshaft.RenderGearShaft;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy
|
public class ClientProxy extends CommonProxy
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public void preInit()
|
|
||||||
{
|
|
||||||
GlobalItemRenderer.register(Mechanical.itemGear.itemID, RenderGear.INSTANCE);
|
|
||||||
GlobalItemRenderer.register(Mechanical.itemGearShaft.itemID, RenderGearShaft.INSTANCE);
|
|
||||||
GlobalItemRenderer.register(Mechanical.itemPipe.itemID, RenderPipe.INSTANCE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
package resonantinduction.mechanical;
|
package resonantinduction.mechanical;
|
||||||
|
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import resonant.content.loader.ModManager;
|
||||||
|
import resonant.content.prefab.itemblock.ItemBlockMetadata;
|
||||||
|
import resonant.engine.content.debug.TileCreativeBuilder;
|
||||||
|
import resonant.lib.network.discriminator.PacketAnnotationManager;
|
||||||
import resonantinduction.core.ResonantTab;
|
import resonantinduction.core.ResonantTab;
|
||||||
import resonantinduction.mechanical.belt.BlockConveyorBelt;
|
|
||||||
import resonantinduction.mechanical.belt.TileConveyorBelt;
|
|
||||||
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
||||||
import resonantinduction.mechanical.fluid.pipe.EnumPipeMaterial;
|
import resonantinduction.mechanical.fluid.pipe.EnumPipeMaterial;
|
||||||
import resonantinduction.mechanical.fluid.pipe.ItemPipe;
|
import resonantinduction.mechanical.fluid.pipe.ItemPipe;
|
||||||
import resonantinduction.mechanical.fluid.transport.TilePump;
|
import resonantinduction.mechanical.fluid.transport.TilePump;
|
||||||
import resonantinduction.mechanical.gear.ItemGear;
|
import resonantinduction.mechanical.gear.ItemGear;
|
||||||
import resonantinduction.mechanical.gearshaft.ItemGearShaft;
|
import resonantinduction.mechanical.gearshaft.ItemGearShaft;
|
||||||
import resonantinduction.mechanical.logistic.belt.BlockDetector;
|
|
||||||
import resonantinduction.mechanical.logistic.belt.TileDetector;
|
import resonantinduction.mechanical.logistic.belt.TileDetector;
|
||||||
import resonantinduction.mechanical.logistic.belt.TileManipulator;
|
|
||||||
import resonantinduction.mechanical.process.crusher.TileMechanicalPiston;
|
import resonantinduction.mechanical.process.crusher.TileMechanicalPiston;
|
||||||
import resonantinduction.mechanical.process.edit.TileBreaker;
|
import resonantinduction.mechanical.process.edit.TileBreaker;
|
||||||
import resonantinduction.mechanical.process.edit.TilePlacer;
|
import resonantinduction.mechanical.process.edit.TilePlacer;
|
||||||
|
@ -22,12 +24,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
import resonant.core.content.debug.BlockCreativeBuilder;
|
|
||||||
import resonant.lib.content.ContentRegistry;
|
|
||||||
import resonant.lib.grid.NodeRegistry;
|
|
||||||
import resonant.lib.network.PacketAnnotation;
|
|
||||||
import resonant.lib.network.PacketHandler;
|
|
||||||
import resonant.lib.prefab.item.ItemBlockMetadata;
|
|
||||||
import resonant.lib.recipe.UniversalRecipe;
|
import resonant.lib.recipe.UniversalRecipe;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
|
@ -39,7 +35,6 @@ import resonantinduction.mechanical.energy.turbine.SchematicWaterTurbine;
|
||||||
import resonantinduction.mechanical.energy.turbine.SchematicWindTurbine;
|
import resonantinduction.mechanical.energy.turbine.SchematicWindTurbine;
|
||||||
import resonantinduction.mechanical.energy.turbine.TileWaterTurbine;
|
import resonantinduction.mechanical.energy.turbine.TileWaterTurbine;
|
||||||
import resonantinduction.mechanical.energy.turbine.TileWindTurbine;
|
import resonantinduction.mechanical.energy.turbine.TileWindTurbine;
|
||||||
import resonantinduction.mechanical.logistic.belt.TileSorter;
|
|
||||||
import resonantinduction.mechanical.process.mixer.TileMixer;
|
import resonantinduction.mechanical.process.mixer.TileMixer;
|
||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.common.Mod.EventHandler;
|
import cpw.mods.fml.common.Mod.EventHandler;
|
||||||
|
@ -49,22 +44,21 @@ import cpw.mods.fml.common.SidedProxy;
|
||||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
import cpw.mods.fml.common.network.NetworkMod;
|
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
import universalelectricity.api.core.grid.NodeRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resonant Induction Mechanical Module
|
* Resonant Induction Mechanical Module
|
||||||
*
|
*
|
||||||
* @author DarkCow, Calclavia
|
* @author DarkCow, Calclavia
|
||||||
*/
|
*/
|
||||||
@Mod(modid = Mechanical.ID, name = Mechanical.NAME, version = Reference.VERSION, dependencies = "before:ThermalExpansion;required-after:" + ResonantInduction.ID + ";after:ResonantInduction|Archaic")
|
@Mod(modid = Mechanical.ID, name = Mechanical.NAME, version = Reference.version(), dependencies = "before:ThermalExpansion;required-after:" + ResonantInduction.ID + ";after:ResonantInduction|Archaic")
|
||||||
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
|
||||||
public class Mechanical
|
public class Mechanical
|
||||||
{
|
{
|
||||||
/** Mod Information */
|
/** Mod Information */
|
||||||
public static final String ID = "ResonantInduction|Mechanical";
|
public static final String ID = "ResonantInduction|Mechanical";
|
||||||
public static final String NAME = Reference.NAME + " Mechanical";
|
public static final String NAME = Reference.name() + " Mechanical";
|
||||||
|
|
||||||
@Instance(ID)
|
@Instance(ID)
|
||||||
public static Mechanical INSTANCE;
|
public static Mechanical INSTANCE;
|
||||||
|
@ -75,7 +69,7 @@ public class Mechanical
|
||||||
@Mod.Metadata(ID)
|
@Mod.Metadata(ID)
|
||||||
public static ModMetadata metadata;
|
public static ModMetadata metadata;
|
||||||
|
|
||||||
public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.config, Settings.idManager, ID).setPrefix(Reference.PREFIX).setTab(ResonantTab.DEFAULT);
|
public static final ModManager contentRegistry = new ModManager().setPrefix(Reference.prefix()).setTab(ResonantTab.tab());
|
||||||
|
|
||||||
// Energy
|
// Energy
|
||||||
public static Item itemGear;
|
public static Item itemGear;
|
||||||
|
@ -107,29 +101,21 @@ public class Mechanical
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent evt)
|
public void preInit(FMLPreInitializationEvent evt)
|
||||||
{
|
{
|
||||||
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy);
|
||||||
MinecraftForge.EVENT_BUS.register(new MicroblockHighlightHandler());
|
MinecraftForge.EVENT_BUS.register(new MicroblockHighlightHandler());
|
||||||
BlockCreativeBuilder.register(new SchematicWindTurbine());
|
TileCreativeBuilder.register(new SchematicWindTurbine());
|
||||||
BlockCreativeBuilder.register(new SchematicWaterTurbine());
|
TileCreativeBuilder.register(new SchematicWaterTurbine());
|
||||||
NodeRegistry.register(IMechanicalNode.class, MechanicalNode.class);
|
NodeRegistry.register(IMechanicalNode.class, MechanicalNode.class);
|
||||||
|
|
||||||
Settings.config.load();
|
itemGear = contentRegistry.newItem(ItemGear.class);
|
||||||
|
itemGearShaft = contentRegistry.newItem(ItemGearShaft.class);
|
||||||
itemGear = contentRegistry.createItem(ItemGear.class);
|
itemPipe = contentRegistry.newItem(ItemPipe.class);
|
||||||
itemGearShaft = contentRegistry.createItem(ItemGearShaft.class);
|
|
||||||
blockWindTurbine = contentRegistry.createBlock(BlockWindTurbine.class, ItemBlockMetadata.class, TileWindTurbine.class);
|
|
||||||
blockWaterTurbine = contentRegistry.createBlock(BlockWaterTurbine.class, ItemBlockMetadata.class, TileWaterTurbine.class);
|
|
||||||
|
|
||||||
blockConveyorBelt = contentRegistry.createTile(BlockConveyorBelt.class, TileConveyorBelt.class);
|
|
||||||
blockManipulator = contentRegistry.createTile(BlockManipulator.class, TileManipulator.class);
|
|
||||||
blockDetector = contentRegistry.createTile(BlockDetector.class, TileDetector.class);
|
|
||||||
// blockRejector = contentRegistry.createTile(BlockRejector.class, TileRejector.class);
|
|
||||||
blockSorter = contentRegistry.newBlock(TileSorter.class);
|
|
||||||
|
|
||||||
|
blockWindTurbine = contentRegistry.newBlock(BlockWindTurbine.class, ItemBlockMetadata.class, TileWindTurbine.class);
|
||||||
|
blockWaterTurbine = contentRegistry.newBlock(BlockWaterTurbine.class, ItemBlockMetadata.class, TileWaterTurbine.class);
|
||||||
|
blockDetector = contentRegistry.newBlock(TileDetector.class);
|
||||||
blockPump = contentRegistry.newBlock(TilePump.class);
|
blockPump = contentRegistry.newBlock(TilePump.class);
|
||||||
|
|
||||||
itemPipe = contentRegistry.createItem(ItemPipe.class);
|
|
||||||
|
|
||||||
// Machines
|
// Machines
|
||||||
blockGrinderWheel = contentRegistry.newBlock(TileGrindingWheel.class);
|
blockGrinderWheel = contentRegistry.newBlock(TileGrindingWheel.class);
|
||||||
blockMixer = contentRegistry.newBlock(TileMixer.class);
|
blockMixer = contentRegistry.newBlock(TileMixer.class);
|
||||||
|
@ -140,20 +126,17 @@ public class Mechanical
|
||||||
blockTilePlacer = contentRegistry.newBlock(TilePlacer.class);
|
blockTilePlacer = contentRegistry.newBlock(TilePlacer.class);
|
||||||
|
|
||||||
proxy.preInit();
|
proxy.preInit();
|
||||||
Settings.config.save();
|
|
||||||
|
|
||||||
ResonantTab.ITEMSTACK = new ItemStack(blockGrinderWheel);
|
ResonantTab.itemStack(new ItemStack(blockGrinderWheel));
|
||||||
|
|
||||||
PacketAnnotation.register(TileWindTurbine.class);
|
PacketAnnotationManager.INSTANCE.register(TileWindTurbine.class);
|
||||||
PacketAnnotation.register(TileWaterTurbine.class);
|
PacketAnnotationManager.INSTANCE.register(TileWaterTurbine.class);
|
||||||
PacketAnnotation.register(TileSorter.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void init(FMLInitializationEvent evt)
|
public void init(FMLInitializationEvent evt)
|
||||||
{
|
{
|
||||||
MultipartMechanical.INSTANCE = new MultipartMechanical();
|
MultipartMechanical.INSTANCE = new MultipartMechanical();
|
||||||
Settings.setModMetadata(metadata, ID, NAME, ResonantInduction.ID);
|
|
||||||
proxy.init();
|
proxy.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,39 +144,39 @@ public class Mechanical
|
||||||
public void postInit(FMLPostInitializationEvent evt)
|
public void postInit(FMLPostInitializationEvent evt)
|
||||||
{
|
{
|
||||||
// Add recipes
|
// Add recipes
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGear, 1, 0), "SWS", "W W", "SWS", 'W', "plankWood", 'S', Item.stick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGear, 1, 0), "SWS", "W W", "SWS", 'W', "plankWood", 'S', Items.stick));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGear, 1, 1), " W ", "WGW", " W ", 'G', new ItemStack(itemGear, 1, 0), 'W', Block.cobblestone));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGear, 1, 1), " W ", "WGW", " W ", 'G', new ItemStack(itemGear, 1, 0), 'W', Blocks.cobblestone));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGear, 1, 2), " W ", "WGW", " W ", 'G', new ItemStack(itemGear, 1, 1), 'W', Item.ingotIron));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGear, 1, 2), " W ", "WGW", " W ", 'G', new ItemStack(itemGear, 1, 1), 'W', Items.iron_ingot));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGearShaft, 1, 0), "S", "S", "S", 'S', Item.stick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGearShaft, 1, 0), "S", "S", "S", 'S', Items.stick));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGearShaft, 1, 1), "S", "G", "S", 'G', new ItemStack(itemGearShaft, 1, 0), 'S', Block.cobblestone));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGearShaft, 1, 1), "S", "G", "S", 'G', new ItemStack(itemGearShaft, 1, 0), 'S', Blocks.cobblestone));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGearShaft, 1, 2), "S", "G", "S", 'G', new ItemStack(itemGearShaft, 1, 1), 'S', Item.ingotIron));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGearShaft, 1, 2), "S", "G", "S", 'G', new ItemStack(itemGearShaft, 1, 1), 'S', Items.iron_ingot));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 4), "III", "GGG", 'I', Item.ingotIron, 'G', itemGear));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 4), "III", "GGG", 'I', Items.iron_ingot, 'G', itemGear));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockManipulator, "SSS", "SRS", "SCS", 'S', Item.ingotIron, 'C', blockConveyorBelt, 'R', Block.blockRedstone));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockManipulator, "SSS", "SRS", "SCS", 'S', Items.iron_ingot, 'C', blockConveyorBelt, 'R', Blocks.redstone_block));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, "SWS", "SRS", "SWS", 'S', Item.ingotIron, 'W', UniversalRecipe.WIRE.get()));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, "SWS", "SRS", "SWS", 'S', Items.iron_ingot, 'W', UniversalRecipe.WIRE.get()));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockSorter, "SSS", "SPS", "SRS", 'P', Block.pistonStickyBase, 'S', Item.ingotIron, 'R', Block.blockRedstone));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockSorter, "SSS", "SPS", "SRS", 'P', Blocks.piston, 'S', Items.iron_ingot, 'R', Blocks.redstone_block));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWindTurbine, 1, 0), "CWC", "WGW", "CWC", 'G', itemGear, 'C', Block.cloth, 'W', Item.stick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWindTurbine, 1, 0), "CWC", "WGW", "CWC", 'G', itemGear, 'C', Blocks.wool, 'W', Items.stick));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWindTurbine, 1, 1), "CWC", "WGW", "CWC", 'G', new ItemStack(blockWindTurbine, 1, 0), 'C', Block.stone, 'W', Item.stick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWindTurbine, 1, 1), "CWC", "WGW", "CWC", 'G', new ItemStack(blockWindTurbine, 1, 0), 'C', Blocks.stone, 'W', Items.stick));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWindTurbine, 1, 2), "CWC", "WGW", "CWC", 'G', new ItemStack(blockWindTurbine, 1, 1), 'C', Item.ingotIron, 'W', Item.stick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWindTurbine, 1, 2), "CWC", "WGW", "CWC", 'G', new ItemStack(blockWindTurbine, 1, 1), 'C', Items.iron_ingot, 'W', Items.stick));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWaterTurbine, 1, 0), "SWS", "WGW", "SWS", 'G', itemGear, 'W', "plankWood", 'S', Item.stick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWaterTurbine, 1, 0), "SWS", "WGW", "SWS", 'G', itemGear, 'W', "plankWood", 'S', Items.stick));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWaterTurbine, 1, 1), "SWS", "WGW", "SWS", 'G', new ItemStack(blockWaterTurbine, 1, 0), 'W', Block.stone, 'S', Item.stick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWaterTurbine, 1, 1), "SWS", "WGW", "SWS", 'G', new ItemStack(blockWaterTurbine, 1, 0), 'W', Blocks.stone, 'S', Items.stick));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWaterTurbine, 1, 2), "SWS", "WGW", "SWS", 'G', new ItemStack(blockWaterTurbine, 1, 1), 'W', UniversalRecipe.PRIMARY_METAL.get(), 'S', Item.stick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWaterTurbine, 1, 2), "SWS", "WGW", "SWS", 'G', new ItemStack(blockWaterTurbine, 1, 1), 'W', UniversalRecipe.PRIMARY_METAL.get(), 'S', Items.stick));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockPump, "PPP", "GGG", "PPP", 'P', itemPipe, 'G', new ItemStack(itemGear, 1, 2)));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockPump, "PPP", "GGG", "PPP", 'P', itemPipe, 'G', new ItemStack(itemGear, 1, 2)));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.CERAMIC.ordinal()), "BBB", " ", "BBB", 'B', Item.brick));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.CERAMIC.ordinal()), "BBB", " ", "BBB", 'B', Items.brick));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.BRONZE.ordinal()), "BBB", " ", "BBB", 'B', "ingotBronze"));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.BRONZE.ordinal()), "BBB", " ", "BBB", 'B', "ingotBronze"));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.PLASTIC.ordinal()), "BBB", " ", "BBB", 'B', UniversalRecipe.RUBBER.get()));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.PLASTIC.ordinal()), "BBB", " ", "BBB", 'B', UniversalRecipe.RUBBER.get()));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.IRON.ordinal()), "BBB", " ", "BBB", 'B', Item.ingotIron));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.IRON.ordinal()), "BBB", " ", "BBB", 'B', Items.iron_ingot));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.STEEL.ordinal()), "BBB", " ", "BBB", 'B', "ingotSteel"));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.STEEL.ordinal()), "BBB", " ", "BBB", 'B', "ingotSteel"));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.FIBERGLASS.ordinal()), "BBB", " ", "BBB", 'B', Item.diamond));
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3, EnumPipeMaterial.FIBERGLASS.ordinal()), "BBB", " ", "BBB", 'B', Items.diamond));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockMechanicalPiston, "SGS", "SPS", "SRS", 'P', Block.pistonBase, 'S', Item.ingotIron, 'R', Item.redstone, 'G', new ItemStack(itemGear, 1, 2)));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockMechanicalPiston, "SGS", "SPS", "SRS", 'P', Blocks.piston, 'S', Items.iron_ingot, 'R', Items.redstone, 'G', new ItemStack(itemGear, 1, 2)));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockGrinderWheel, "III", "LGL", "III", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'L', "logWood", 'G', itemGear));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockGrinderWheel, "III", "LGL", "III", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'L', "logWood", 'G', itemGear));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockMixer, "IGI", "IGI", "IGI", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'G', itemGear));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockMixer, "IGI", "IGI", "IGI", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'G', itemGear));
|
||||||
|
|
||||||
// block break and placer recipes
|
// block break and placer recipes
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockTileBreaker, "CGC", "CPC", "CDC", 'C', Block.cobblestone, 'G', itemGear, 'P', Block.pistonBase, 'D', Item.pickaxeDiamond));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockTileBreaker, "CGC", "CPC", "CDC", 'C', Blocks.cobblestone, 'G', itemGear, 'P', Blocks.piston, 'D', Items.diamond_pickaxe));
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockTilePlacer, "CGC", "CSC", "CRC", 'C', Block.cobblestone, 'G', itemGear, 'S', Item.ingotIron, 'R', Block.blockRedstone));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockTilePlacer, "CGC", "CSC", "CRC", 'C', Blocks.cobblestone, 'G', itemGear, 'S', Items.iron_ingot, 'R', Blocks.redstone_block));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,22 @@ package resonantinduction.mechanical.energy.grid;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import resonant.content.prefab.java.TileAdvanced;
|
import resonant.content.prefab.java.TileAdvanced;
|
||||||
import resonant.engine.ResonantEngine;
|
import resonant.engine.ResonantEngine;
|
||||||
import resonant.lib.network.handle.TPacketIDReceiver;
|
import resonant.lib.network.ByteBufWrapper;
|
||||||
|
import resonant.lib.network.discriminator.PacketTile;
|
||||||
|
import resonant.lib.network.discriminator.PacketType;
|
||||||
|
import resonant.lib.network.handle.IPacketIDReceiver;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
import universalelectricity.api.core.grid.INode;
|
import universalelectricity.api.core.grid.INode;
|
||||||
import universalelectricity.api.core.grid.INodeProvider;
|
import universalelectricity.api.core.grid.INodeProvider;
|
||||||
|
@ -23,7 +29,7 @@ import com.google.common.io.ByteArrayDataInput;
|
||||||
/** Prefab for resonantinduction.mechanical tiles
|
/** Prefab for resonantinduction.mechanical tiles
|
||||||
*
|
*
|
||||||
* @author Calclavia */
|
* @author Calclavia */
|
||||||
public abstract class TileMechanical extends TileAdvanced implements INodeProvider, TPacketIDReceiver
|
public abstract class TileMechanical extends TileAdvanced implements INodeProvider, IPacketIDReceiver
|
||||||
{
|
{
|
||||||
protected static final int PACKET_NBT = 0;
|
protected static final int PACKET_NBT = 0;
|
||||||
protected static final int PACKET_VELOCITY = 1;
|
protected static final int PACKET_VELOCITY = 1;
|
||||||
|
@ -132,16 +138,16 @@ public abstract class TileMechanical extends TileAdvanced implements INodeProvid
|
||||||
{
|
{
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
writeToNBT(tag);
|
writeToNBT(tag);
|
||||||
return References.PACKET_TILE.getPacketWithID(PACKET_NBT, this, tag);
|
return ResonantEngine.instance.packetHandler.toMCPacket(new PacketTile(this, PACKET_NBT, tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendRotationPacket()
|
private void sendRotationPacket()
|
||||||
{
|
{
|
||||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_VELOCITY, this, mechanicalNode.angularVelocity, mechanicalNode.torque), worldObj, new Vector3(this), 20);
|
ResonantEngine.instance.packetHandler.sendToAllAround(new PacketTile(this, PACKET_VELOCITY, mechanicalNode.angularVelocity, mechanicalNode.torque), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
public boolean read(ByteBuf data, int id, EntityPlayer player, PacketType type)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -149,7 +155,7 @@ public abstract class TileMechanical extends TileAdvanced implements INodeProvid
|
||||||
{
|
{
|
||||||
if (id == PACKET_NBT)
|
if (id == PACKET_NBT)
|
||||||
{
|
{
|
||||||
readFromNBT(PacketHandler.readNBTTagCompound(data));
|
readFromNBT(ByteBufUtils.readTag(data));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (id == PACKET_VELOCITY)
|
else if (id == PACKET_VELOCITY)
|
||||||
|
@ -160,7 +166,7 @@ public abstract class TileMechanical extends TileAdvanced implements INodeProvid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -11,19 +12,18 @@ import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import resonant.lib.render.EnumColor;
|
import resonant.lib.render.EnumColor;
|
||||||
import resonant.lib.utility.LanguageUtility;
|
import resonant.lib.utility.LanguageUtility;
|
||||||
import universalelectricity.api.energy.UnitDisplay;
|
|
||||||
import universalelectricity.api.energy.UnitDisplay.Unit;
|
|
||||||
import codechicken.lib.vec.BlockCoord;
|
import codechicken.lib.vec.BlockCoord;
|
||||||
import codechicken.lib.vec.Vector3;
|
import codechicken.lib.vec.Vector3;
|
||||||
import codechicken.multipart.JItemMultiPart;
|
import codechicken.multipart.JItemMultiPart;
|
||||||
import codechicken.multipart.MultiPartRegistry;
|
import codechicken.multipart.MultiPartRegistry;
|
||||||
import codechicken.multipart.TMultiPart;
|
import codechicken.multipart.TMultiPart;
|
||||||
|
import universalelectricity.api.UnitDisplay;
|
||||||
|
|
||||||
public class ItemPipe extends JItemMultiPart
|
public class ItemPipe extends JItemMultiPart
|
||||||
{
|
{
|
||||||
public ItemPipe(int id)
|
public ItemPipe()
|
||||||
{
|
{
|
||||||
super(id);
|
super();
|
||||||
this.setHasSubtypes(true);
|
this.setHasSubtypes(true);
|
||||||
this.setMaxDamage(0);
|
this.setMaxDamage(0);
|
||||||
}
|
}
|
||||||
|
@ -58,13 +58,13 @@ public class ItemPipe extends JItemMultiPart
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.pipe.rate").replace("%v", "" + EnumColor.ORANGE + UnitDisplay.getDisplay(EnumPipeMaterial.values()[itemstack.getItemDamage()].maxFlowRate * 20, Unit.LITER) + "/s"));
|
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.pipe.rate").replace("%v", "" + EnumColor.ORANGE + new UnitDisplay(UnitDisplay.Unit.LITER, EnumPipeMaterial.values()[itemstack.getItemDamage()].maxFlowRate * 20) + "/s"));
|
||||||
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.pipe.pressure").replace("%v", "" + EnumColor.ORANGE + EnumPipeMaterial.values()[itemstack.getItemDamage()].maxPressure + " Pa"));
|
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.pipe.pressure").replace("%v", "" + EnumColor.ORANGE + EnumPipeMaterial.values()[itemstack.getItemDamage()].maxPressure + " Pa"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
|
public void getSubItems(Item itemID, CreativeTabs tab, List listToAddTo)
|
||||||
{
|
{
|
||||||
for (EnumPipeMaterial material : EnumPipeMaterial.values())
|
for (EnumPipeMaterial material : EnumPipeMaterial.values())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package resonantinduction.mechanical.fluid.pipe;
|
package resonantinduction.mechanical.fluid.pipe;
|
||||||
|
|
||||||
|
import codechicken.lib.vec.Cuboid6;
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -12,20 +13,14 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.FluidTank;
|
import net.minecraftforge.fluids.FluidTank;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import resonant.api.grid.INode;
|
|
||||||
import resonant.core.ResonantEngine;
|
|
||||||
import resonant.lib.type.EvictingList;
|
import resonant.lib.type.EvictingList;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
import resonantinduction.core.grid.fluid.pressure.FluidPressureNode;
|
import resonantinduction.core.grid.fluid.pressure.FluidPressureNode;
|
||||||
import resonantinduction.core.grid.fluid.IPressureNodeProvider;
|
|
||||||
import resonantinduction.core.prefab.part.PartFramedNode;
|
|
||||||
import resonantinduction.mechanical.Mechanical;
|
import resonantinduction.mechanical.Mechanical;
|
||||||
import codechicken.lib.data.MCDataInput;
|
import codechicken.lib.data.MCDataInput;
|
||||||
import codechicken.lib.render.CCRenderState;
|
import codechicken.lib.render.CCRenderState;
|
||||||
import codechicken.lib.render.IconTransformation;
|
|
||||||
import codechicken.lib.render.RenderUtils;
|
import codechicken.lib.render.RenderUtils;
|
||||||
import codechicken.lib.vec.Translation;
|
import codechicken.lib.vec.Translation;
|
||||||
import codechicken.microblock.IHollowConnect;
|
|
||||||
import codechicken.multipart.ControlKeyModifer;
|
import codechicken.multipart.ControlKeyModifer;
|
||||||
import codechicken.multipart.JNormalOcclusion;
|
import codechicken.multipart.JNormalOcclusion;
|
||||||
import codechicken.multipart.TSlottedPart;
|
import codechicken.multipart.TSlottedPart;
|
||||||
|
@ -268,4 +263,14 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, FluidPressureNode
|
||||||
frame.closeDebugFrame();
|
frame.closeDebugFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<Cuboid6> getOcclusionBoxes() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlotMask() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -10,11 +10,11 @@ import javax.swing.table.AbstractTableModel;
|
||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import resonant.api.grid.INode;
|
|
||||||
import resonant.api.grid.INodeProvider;
|
|
||||||
import resonantinduction.core.debug.FrameNodeDebug;
|
import resonantinduction.core.debug.FrameNodeDebug;
|
||||||
import resonantinduction.core.debug.UpdatePanel;
|
import resonantinduction.core.debug.UpdatePanel;
|
||||||
import resonantinduction.core.debug.UpdatedLabel;
|
import resonantinduction.core.debug.UpdatedLabel;
|
||||||
|
import universalelectricity.api.core.grid.INode;
|
||||||
|
import universalelectricity.api.core.grid.INodeProvider;
|
||||||
|
|
||||||
/** Java GUI used to help debug pipe information
|
/** Java GUI used to help debug pipe information
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,8 +16,8 @@ import resonantinduction.core.Reference;
|
||||||
|
|
||||||
public class RenderPump extends TileEntitySpecialRenderer
|
public class RenderPump extends TileEntitySpecialRenderer
|
||||||
{
|
{
|
||||||
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "pump.tcn");
|
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain(), Reference.modelDirectory() + "pump.tcn"));
|
||||||
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "pump.png");
|
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.domain(), Reference.modelDirectory() + "pump.png");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
|
||||||
|
@ -29,7 +29,7 @@ public class RenderPump extends TileEntitySpecialRenderer
|
||||||
|
|
||||||
GL11.glRotatef(-90, 0, 1, 0);
|
GL11.glRotatef(-90, 0, 1, 0);
|
||||||
|
|
||||||
if (tile.worldObj != null)
|
if (tile.getWorldObj() != null)
|
||||||
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection());
|
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection());
|
||||||
|
|
||||||
bindTexture(TEXTURE);
|
bindTexture(TEXTURE);
|
||||||
|
|
|
@ -14,7 +14,7 @@ import resonantinduction.core.grid.fluid.pressure.FluidPressureNode;
|
||||||
import universalelectricity.api.core.grid.INode;
|
import universalelectricity.api.core.grid.INode;
|
||||||
import universalelectricity.core.transform.vector.Vector3;
|
import universalelectricity.core.transform.vector.Vector3;
|
||||||
|
|
||||||
public class TilePump extends TileMechanical implements IPressureNodeProvider, IRotatable
|
public class TilePump extends TileMechanical implements IRotatable, IFluidHandler
|
||||||
{
|
{
|
||||||
private final FluidPressureNode pressureNode;
|
private final FluidPressureNode pressureNode;
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ public class TilePump extends TileMechanical implements IPressureNodeProvider, I
|
||||||
{
|
{
|
||||||
super(Material.iron);
|
super(Material.iron);
|
||||||
|
|
||||||
|
normalRender(false);
|
||||||
|
isOpaqueCube(false);
|
||||||
|
customItemRender(true);
|
||||||
|
textureName("material_steel");
|
||||||
pressureNode = new FluidPressureNode(this)
|
pressureNode = new FluidPressureNode(this)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,12 +59,6 @@ public class TilePump extends TileMechanical implements IPressureNodeProvider, I
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
normalRender = false;
|
|
||||||
isOpaqueCube = false;
|
|
||||||
customItemRender = true;
|
|
||||||
rotationMask = Byte.parseByte("111111", 2);
|
|
||||||
textureName = "material_steel";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,9 +76,9 @@ public class TilePump extends TileMechanical implements IPressureNodeProvider, I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void update()
|
||||||
{
|
{
|
||||||
super.updateEntity();
|
super.update();
|
||||||
|
|
||||||
if (!worldObj.isRemote && mechanicalNode.getPower() > 0)
|
if (!worldObj.isRemote && mechanicalNode.getPower() > 0)
|
||||||
{
|
{
|
||||||
|
@ -145,12 +143,6 @@ public class TilePump extends TileMechanical implements IPressureNodeProvider, I
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidTank getPressureTank()
|
|
||||||
{
|
|
||||||
return new FluidTank(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public INode getNode(Class<? extends INode> nodeType, ForgeDirection from)
|
public INode getNode(Class<? extends INode> nodeType, ForgeDirection from)
|
||||||
{
|
{
|
||||||
|
@ -160,12 +152,6 @@ public class TilePump extends TileMechanical implements IPressureNodeProvider, I
|
||||||
return super.getNode(nodeType, from);
|
return super.getNode(nodeType, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFluidChanged()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForgeDirection getDirection() {
|
public ForgeDirection getDirection() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package resonantinduction.mechanical.gear;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import resonant.lib.multiblock.MultiBlockHandler;
|
import resonant.lib.multiblock.reference.MultiBlockHandler;
|
||||||
import universalelectricity.core.transform.vector.Vector3;
|
import universalelectricity.core.transform.vector.Vector3;
|
||||||
import codechicken.multipart.TMultiPart;
|
import codechicken.multipart.TMultiPart;
|
||||||
import codechicken.multipart.TileMultipart;
|
import codechicken.multipart.TileMultipart;
|
||||||
|
|
|
@ -2,13 +2,13 @@ package resonantinduction.mechanical.gear;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import resonant.api.grid.INodeProvider;
|
|
||||||
import resonantinduction.core.interfaces.IMechanicalNode;
|
import resonantinduction.core.interfaces.IMechanicalNode;
|
||||||
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
||||||
import resonantinduction.mechanical.gearshaft.PartGearShaft;
|
import resonantinduction.mechanical.gearshaft.PartGearShaft;
|
||||||
import codechicken.lib.vec.Rotation;
|
import codechicken.lib.vec.Rotation;
|
||||||
import codechicken.multipart.TMultiPart;
|
import codechicken.multipart.TMultiPart;
|
||||||
import codechicken.multipart.TileMultipart;
|
import codechicken.multipart.TileMultipart;
|
||||||
|
import universalelectricity.api.core.grid.INodeProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node for the gear
|
* Node for the gear
|
||||||
|
@ -143,7 +143,7 @@ public class GearNode extends MechanicalNode
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
ForgeDirection checkDir = ForgeDirection.getOrientation(Rotation.rotateSide(gear().placementSide.ordinal(), i));
|
ForgeDirection checkDir = ForgeDirection.getOrientation(Rotation.rotateSide(gear().placementSide.ordinal(), i));
|
||||||
TileEntity checkTile = new universalelectricity.core.transform.vector.Vector3(gear().tile()).add(checkDir, displaceCheck).getTileEntity(world());
|
TileEntity checkTile = new universalelectricity.core.transform.vector.Vector3(gear().tile()).add(checkDir).getTileEntity(world());
|
||||||
|
|
||||||
if (!getConnections().containsValue(checkDir) && checkTile instanceof INodeProvider)
|
if (!getConnections().containsValue(checkDir) && checkTile instanceof INodeProvider)
|
||||||
{
|
{
|
||||||
|
@ -284,9 +284,9 @@ public class GearNode extends MechanicalNode
|
||||||
{
|
{
|
||||||
universalelectricity.core.transform.vector.Vector3 deltaPos = with.position().subtract(position());
|
universalelectricity.core.transform.vector.Vector3 deltaPos = with.position().subtract(position());
|
||||||
|
|
||||||
boolean caseX = gear().placementSide.offsetX != 0 && deltaPos.y == 0 && deltaPos.z == 0;
|
boolean caseX = gear().placementSide.offsetX != 0 && deltaPos.y() == 0 && deltaPos.z() == 0;
|
||||||
boolean caseY = gear().placementSide.offsetY != 0 && deltaPos.x == 0 && deltaPos.z == 0;
|
boolean caseY = gear().placementSide.offsetY != 0 && deltaPos.x() == 0 && deltaPos.z() == 0;
|
||||||
boolean caseZ = gear().placementSide.offsetZ != 0 && deltaPos.x == 0 && deltaPos.y == 0;
|
boolean caseZ = gear().placementSide.offsetZ != 0 && deltaPos.x() == 0 && deltaPos.y() == 0;
|
||||||
|
|
||||||
if (caseX || caseY || caseZ)
|
if (caseX || caseY || caseZ)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,13 +10,9 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import resonant.api.grid.INode;
|
import resonant.lib.multiblock.reference.IMultiBlockStructure;
|
||||||
import resonant.api.grid.INodeProvider;
|
|
||||||
import resonant.lib.multiblock.IMultiBlockStructure;
|
|
||||||
import resonant.lib.multiblock.MultiBlockHandler;
|
|
||||||
import resonant.lib.utility.WrenchUtility;
|
import resonant.lib.utility.WrenchUtility;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
import resonantinduction.mechanical.gear.ItemHandCrank;
|
|
||||||
import resonantinduction.mechanical.Mechanical;
|
import resonantinduction.mechanical.Mechanical;
|
||||||
import resonantinduction.mechanical.energy.grid.PartMechanical;
|
import resonantinduction.mechanical.energy.grid.PartMechanical;
|
||||||
import codechicken.lib.vec.Cuboid6;
|
import codechicken.lib.vec.Cuboid6;
|
||||||
|
@ -27,6 +23,9 @@ import codechicken.microblock.FaceMicroClass;
|
||||||
import codechicken.multipart.ControlKeyModifer;
|
import codechicken.multipart.ControlKeyModifer;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import universalelectricity.api.core.grid.INode;
|
||||||
|
import universalelectricity.core.transform.rotation.EulerAngle;
|
||||||
|
import universalelectricity.core.transform.vector.VectorWorld;
|
||||||
|
|
||||||
/** We assume all the force acting on the gear is 90 degrees.
|
/** We assume all the force acting on the gear is 90 degrees.
|
||||||
*
|
*
|
||||||
|
@ -95,7 +94,7 @@ public class PartGear extends PartMechanical implements IMultiBlockStructure<Par
|
||||||
|
|
||||||
isClockwiseCrank = player.isSneaking();
|
isClockwiseCrank = player.isSneaking();
|
||||||
getMultiBlock().get().manualCrankTime = 20;
|
getMultiBlock().get().manualCrankTime = 20;
|
||||||
world().playSoundEffect(x() + 0.5, y() + 0.5, z() + 0.5, Reference.PREFIX + "gearCrank", 0.5f, 0.9f + world().rand.nextFloat() * 0.2f);
|
world().playSoundEffect(x() + 0.5, y() + 0.5, z() + 0.5, Reference.prefix() + "gearCrank", 0.5f, 0.9f + world().rand.nextFloat() * 0.2f);
|
||||||
player.addExhaustion(0.01f);
|
player.addExhaustion(0.01f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -189,32 +188,7 @@ public class PartGear extends PartMechanical implements IMultiBlockStructure<Par
|
||||||
@Override
|
@Override
|
||||||
public universalelectricity.core.transform.vector.Vector3[] getMultiBlockVectors()
|
public universalelectricity.core.transform.vector.Vector3[] getMultiBlockVectors()
|
||||||
{
|
{
|
||||||
Set<universalelectricity.core.transform.vector.Vector3> vectors = new HashSet<universalelectricity.core.transform.vector.Vector3>();
|
return (universalelectricity.core.transform.vector.Vector3[])new universalelectricity.core.transform.vector.Vector3(this.x(), this.y(), this.z()).getAround(this.world(), placementSide, 1).toArray();
|
||||||
ForgeDirection dir = placementSide;
|
|
||||||
|
|
||||||
universalelectricity.core.transform.vector.Vector3 rotationalAxis = universalelectricity.core.transform.vector.Vector3.UP();
|
|
||||||
|
|
||||||
if (placementSide == ForgeDirection.NORTH || placementSide == ForgeDirection.SOUTH)
|
|
||||||
{
|
|
||||||
rotationalAxis = universalelectricity.core.transform.vector.Vector3.EAST();
|
|
||||||
}
|
|
||||||
else if (placementSide == ForgeDirection.WEST || placementSide == ForgeDirection.EAST)
|
|
||||||
{
|
|
||||||
rotationalAxis = universalelectricity.core.transform.vector.Vector3.SOUTH();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int x = -1; x <= 1; x++)
|
|
||||||
{
|
|
||||||
for (int z = -1; z <= 1; z++)
|
|
||||||
{
|
|
||||||
universalelectricity.core.transform.vector.Vector3 vector = new universalelectricity.core.transform.vector.Vector3(x, 0, z);
|
|
||||||
vector.rotate(90, rotationalAxis);
|
|
||||||
vector = vector.round();
|
|
||||||
vectors.add(vector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vectors.toArray(new universalelectricity.core.transform.vector.Vector3[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -238,7 +212,7 @@ public class PartGear extends PartMechanical implements IMultiBlockStructure<Par
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiBlockHandler<PartGear> getMultiBlock()
|
public GearMultiBlockHandler getMultiBlock()
|
||||||
{
|
{
|
||||||
if (multiBlock == null)
|
if (multiBlock == null)
|
||||||
multiBlock = new GearMultiBlockHandler(this);
|
multiBlock = new GearMultiBlockHandler(this);
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package resonantinduction.mechanical.gear;
|
package resonantinduction.mechanical.gear;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.client.IItemRenderer;
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||||
import net.minecraftforge.client.model.IModelCustom;
|
import net.minecraftforge.client.model.IModelCustom;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import resonant.api.items.ISimpleItemRenderer;
|
import resonant.content.prefab.scala.render.ISimpleItemRenderer;
|
||||||
import resonant.lib.render.RenderUtility;
|
import resonant.lib.render.RenderUtility;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
@ -17,7 +19,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
public class RenderGear implements ISimpleItemRenderer
|
public class RenderGear implements ISimpleItemRenderer
|
||||||
{
|
{
|
||||||
public static final RenderGear INSTANCE = new RenderGear();
|
public static final RenderGear INSTANCE = new RenderGear();
|
||||||
public final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "gears.obj");
|
public final IModelCustom MODEL = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain(), "gears.obj"));
|
||||||
|
|
||||||
|
|
||||||
public void renderGear(int side, int tier, boolean isLarge, double angle)
|
public void renderGear(int side, int tier, boolean isLarge, double angle)
|
||||||
|
@ -25,16 +27,16 @@ public class RenderGear implements ISimpleItemRenderer
|
||||||
switch (tier)
|
switch (tier)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
|
RenderUtility.bind(Reference.blockTextureDirectory() + "planks_oak.png");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "cobblestone.png");
|
RenderUtility.bind(Reference.blockTextureDirectory() + "cobblestone.png");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "iron_block.png");
|
RenderUtility.bind(Reference.blockTextureDirectory() + "iron_block.png");
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "pumpkin_top.png");
|
RenderUtility.bind(Reference.blockTextureDirectory() + "pumpkin_top.png");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +68,7 @@ public class RenderGear implements ISimpleItemRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderInventoryItem(ItemStack itemStack)
|
public void renderInventoryItem(IItemRenderer.ItemRenderType type, ItemStack itemStack, Object... data)
|
||||||
{
|
{
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
renderGear(-1, itemStack.getItemDamage(), false, 0);
|
renderGear(-1, itemStack.getItemDamage(), false, 0);
|
||||||
|
|
|
@ -6,10 +6,10 @@ import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import resonant.api.grid.INodeProvider;
|
|
||||||
import resonantinduction.core.interfaces.IMechanicalNode;
|
import resonantinduction.core.interfaces.IMechanicalNode;
|
||||||
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
||||||
import resonantinduction.mechanical.gear.PartGear;
|
import resonantinduction.mechanical.gear.PartGear;
|
||||||
|
import universalelectricity.api.core.grid.INodeProvider;
|
||||||
import universalelectricity.core.transform.vector.Vector3;
|
import universalelectricity.core.transform.vector.Vector3;
|
||||||
|
|
||||||
public class GearShaftNode extends MechanicalNode
|
public class GearShaftNode extends MechanicalNode
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import resonantinduction.core.prefab.part.IHighlight;
|
import resonantinduction.core.prefab.part.IHighlight;
|
||||||
|
@ -15,9 +16,9 @@ import codechicken.multipart.TMultiPart;
|
||||||
|
|
||||||
public class ItemGearShaft extends JItemMultiPart implements IHighlight
|
public class ItemGearShaft extends JItemMultiPart implements IHighlight
|
||||||
{
|
{
|
||||||
public ItemGearShaft(int id)
|
public ItemGearShaft()
|
||||||
{
|
{
|
||||||
super(id);
|
super();
|
||||||
setHasSubtypes(true);
|
setHasSubtypes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ public class ItemGearShaft extends JItemMultiPart implements IHighlight
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
|
public void getSubItems(Item itemID, CreativeTabs tab, List listToAddTo)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,40 +1,43 @@
|
||||||
package resonantinduction.mechanical.gearshaft;
|
package resonantinduction.mechanical.gearshaft;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.glRotatef;
|
import static org.lwjgl.opengl.GL11.glRotatef;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.client.IItemRenderer;
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||||
import net.minecraftforge.client.model.IModelCustom;
|
import net.minecraftforge.client.model.IModelCustom;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import resonant.api.items.ISimpleItemRenderer;
|
import resonant.content.prefab.scala.render.ISimpleItemRenderer;
|
||||||
import resonant.lib.render.RenderUtility;
|
import resonant.lib.render.RenderUtility;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class RenderGearShaft implements ISimpleItemRenderer
|
public class RenderGearShaft implements ISimpleItemRenderer
|
||||||
{
|
{
|
||||||
public static final RenderGearShaft INSTANCE = new RenderGearShaft();
|
public static final RenderGearShaft INSTANCE = new RenderGearShaft();
|
||||||
public final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "gears.obj");
|
public final IModelCustom MODEL = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain(), "gears.obj"));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderInventoryItem(ItemStack itemStack)
|
public void renderInventoryItem(IItemRenderer.ItemRenderType type, ItemStack itemStack, Object... data)
|
||||||
{
|
{
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
|
|
||||||
switch (itemStack.getItemDamage())
|
switch (itemStack.getItemDamage())
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
|
RenderUtility.bind(Reference.blockTextureDirectory() + "planks_oak.png");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "cobblestone.png");
|
RenderUtility.bind(Reference.blockTextureDirectory() + "cobblestone.png");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "iron_block.png");
|
RenderUtility.bind(Reference.blockTextureDirectory() + "iron_block.png");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +70,13 @@ public class RenderGearShaft implements ISimpleItemRenderer
|
||||||
switch (part.tier)
|
switch (part.tier)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
|
RenderUtility.bind(Reference.blockTextureDirectory() + "planks_oak.png");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "cobblestone.png");
|
RenderUtility.bind(Reference.blockTextureDirectory() + "cobblestone.png");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "iron_block.png");
|
RenderUtility.bind(Reference.blockTextureDirectory() + "iron_block.png");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,146 +0,0 @@
|
||||||
package resonantinduction.mechanical.logistic.belt;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.IIcon;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.archaic.filter.imprint.BlockImprintable;
|
|
||||||
import universalelectricity.api.UniversalElectricity;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/** @author Briman0094 */
|
|
||||||
public class BlockDetector extends BlockImprintable
|
|
||||||
{
|
|
||||||
IIcon front_red, front_green, side_green, side_red;
|
|
||||||
|
|
||||||
public BlockDetector(int id)
|
|
||||||
{
|
|
||||||
super(id, UniversalElectricity.machine);
|
|
||||||
setTextureName(Reference.PREFIX + "material_metal_side");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public void registerIcons(IIconRegister iconReg)
|
|
||||||
{
|
|
||||||
front_green = iconReg.registerIcon(Reference.PREFIX + "detector_front_green");
|
|
||||||
front_red = iconReg.registerIcon(Reference.PREFIX + "detector_front_red");
|
|
||||||
side_green = iconReg.registerIcon(Reference.PREFIX + "detector_side_green");
|
|
||||||
side_red = iconReg.registerIcon(Reference.PREFIX + "detector_side_red");
|
|
||||||
super.registerIcons(iconReg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public IIcon getBlockTexture(IBlockAccess iBlockAccess, int x, int y, int z, int side)
|
|
||||||
{
|
|
||||||
boolean isInverted = false;
|
|
||||||
boolean isFront = false;
|
|
||||||
TileEntity tileEntity = iBlockAccess.getTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity instanceof TileDetector)
|
|
||||||
{
|
|
||||||
isFront = side == ((TileDetector) tileEntity).getDirection().ordinal();
|
|
||||||
isInverted = ((TileDetector) tileEntity).isInverted();
|
|
||||||
}
|
|
||||||
|
|
||||||
return isInverted ? (isFront ? front_red : side_red) : (isFront ? front_green : side_green);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public IIcon getIcon(int side, int metadata)
|
|
||||||
{
|
|
||||||
if (side == ForgeDirection.SOUTH.ordinal())
|
|
||||||
{
|
|
||||||
return front_green;
|
|
||||||
}
|
|
||||||
|
|
||||||
return side_green;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity instanceof TileDetector)
|
|
||||||
{
|
|
||||||
((TileDetector) tileEntity).toggleInversion();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
|
|
||||||
{
|
|
||||||
if (!canBlockStay(world, x, y, z))
|
|
||||||
{
|
|
||||||
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
|
||||||
world.setBlock(x, y, z, 0, 0, 3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isBlockNormalCube(World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isBlockSolid(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int direction)
|
|
||||||
{
|
|
||||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity instanceof TileDetector)
|
|
||||||
{
|
|
||||||
return ((TileDetector) tileEntity).isPoweringTo(ForgeDirection.getOrientation(direction));
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int direction)
|
|
||||||
{
|
|
||||||
return isProvidingStrongPower(world, x, y, z, direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return new TileDetector();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -14,7 +14,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
public class RenderRejector extends RenderImprintable
|
public class RenderRejector extends RenderImprintable
|
||||||
{
|
{
|
||||||
public static final ModelRejectorPiston MODEL = new ModelRejectorPiston();
|
public static final ModelRejectorPiston MODEL = new ModelRejectorPiston();
|
||||||
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "rejector.png");
|
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.domain(), Reference.modelPath() + "rejector.png");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||||
|
|
|
@ -2,25 +2,43 @@ package resonantinduction.mechanical.logistic.belt;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.packet.Packet;
|
import net.minecraft.network.Packet;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import resonant.lib.network.IPacketReceiver;
|
import resonant.content.spatial.block.SpatialBlock;
|
||||||
import resonant.lib.network.PacketHandler;
|
import resonant.engine.ResonantEngine;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonant.lib.network.discriminator.PacketTile;
|
||||||
|
import resonant.lib.network.discriminator.PacketType;
|
||||||
|
import resonant.lib.network.handle.IPacketIDReceiver;
|
||||||
import resonantinduction.archaic.filter.imprint.TileFilterable;
|
import resonantinduction.archaic.filter.imprint.TileFilterable;
|
||||||
|
import resonantinduction.core.Reference;
|
||||||
import resonantinduction.mechanical.Mechanical;
|
import resonantinduction.mechanical.Mechanical;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
public class TileDetector extends TileFilterable implements IPacketIDReceiver
|
||||||
|
|
||||||
public class TileDetector extends TileFilterable implements IPacketReceiver
|
|
||||||
{
|
{
|
||||||
private boolean powering = false;
|
private boolean powering = false;
|
||||||
|
IIcon front_red, front_green, side_green, side_red;
|
||||||
|
|
||||||
|
public TileDetector()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
textureName(Reference.prefix() + "material_metal_side");
|
||||||
|
this.isOpaqueCube(false);
|
||||||
|
this.normalRender(false);
|
||||||
|
this.canProvidePower(true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void update()
|
||||||
|
@ -72,7 +90,7 @@ public class TileDetector extends TileFilterable implements IPacketReceiver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketHandler.sendPacketToClients(getDescriptionPacket());
|
ResonantEngine.instance.packetHandler.sendToAllAround(new PacketTile(this, 0, this.isInverted()), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,8 +98,8 @@ public class TileDetector extends TileFilterable implements IPacketReceiver
|
||||||
@Override
|
@Override
|
||||||
public void invalidate()
|
public void invalidate()
|
||||||
{
|
{
|
||||||
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, Mechanical.blockDetector.blockID);
|
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, Mechanical.blockDetector);
|
||||||
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord + 1, this.zCoord, Mechanical.blockDetector.blockID);
|
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord + 1, this.zCoord, Mechanical.blockDetector);
|
||||||
super.invalidate();
|
super.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,13 +122,15 @@ public class TileDetector extends TileFilterable implements IPacketReceiver
|
||||||
@Override
|
@Override
|
||||||
public Packet getDescriptionPacket()
|
public Packet getDescriptionPacket()
|
||||||
{
|
{
|
||||||
return ResonantInduction.PACKET_TILE.getPacket(this, this.isInverted());
|
return ResonantEngine.instance.packetHandler.toMCPacket(new PacketTile(this, 0, this.isInverted()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
public boolean read(ByteBuf data, int id, EntityPlayer player, PacketType type)
|
||||||
{
|
{
|
||||||
|
if(id == 0)
|
||||||
this.setInverted(data.readBoolean());
|
this.setInverted(data.readBoolean());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int isPoweringTo(ForgeDirection side)
|
public int isPoweringTo(ForgeDirection side)
|
||||||
|
@ -122,4 +142,53 @@ public class TileDetector extends TileFilterable implements IPacketReceiver
|
||||||
{
|
{
|
||||||
return this.isPoweringTo(side) > 0;
|
return this.isPoweringTo(side) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void registerIcons(IIconRegister iconReg)
|
||||||
|
{
|
||||||
|
SpatialBlock.icon().put("detector_front_green", iconReg.registerIcon(Reference.prefix() + "detector_front_green"));
|
||||||
|
SpatialBlock.icon().put("detector_front_red", iconReg.registerIcon(Reference.prefix() + "detector_front_red"));
|
||||||
|
SpatialBlock.icon().put("detector_side_green", iconReg.registerIcon(Reference.prefix() + "detector_side_green"));
|
||||||
|
SpatialBlock.icon().put("detector_side_red", iconReg.registerIcon(Reference.prefix() + "detector_side_red"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public IIcon getIcon(int side, int metadata)
|
||||||
|
{
|
||||||
|
if (side == ForgeDirection.SOUTH.ordinal())
|
||||||
|
{
|
||||||
|
return SpatialBlock.icon().get("detector_front_green");
|
||||||
|
}
|
||||||
|
|
||||||
|
return SpatialBlock.icon().get("detector_side_green");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public IIcon getIcon(IBlockAccess iBlockAccess, int side)
|
||||||
|
{
|
||||||
|
boolean isInverted = false;
|
||||||
|
boolean isFront = false;
|
||||||
|
TileEntity tileEntity = iBlockAccess.getTileEntity(x(), y(), z());
|
||||||
|
|
||||||
|
if (tileEntity instanceof TileDetector)
|
||||||
|
{
|
||||||
|
isFront = side == ((TileDetector) tileEntity).getDirection().ordinal();
|
||||||
|
isInverted = ((TileDetector) tileEntity).isInverted();
|
||||||
|
}
|
||||||
|
|
||||||
|
return isInverted ? (isFront ? front_red : side_red) : (isFront ? front_green : side_green);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStrongRedstonePower(IBlockAccess access, int side)
|
||||||
|
{
|
||||||
|
if(side != getDirection().ordinal())
|
||||||
|
{
|
||||||
|
return powering ? 15 : 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,25 +2,26 @@ package resonantinduction.mechanical.logistic.belt;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.packet.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import resonant.api.IEntityConveyor;
|
import resonant.api.IEntityConveyor;
|
||||||
import resonant.lib.network.IPacketReceiverWithID;
|
import resonant.engine.ResonantEngine;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonant.lib.network.discriminator.PacketTile;
|
||||||
|
import resonant.lib.network.discriminator.PacketType;
|
||||||
|
import resonant.lib.network.handle.IPacketIDReceiver;
|
||||||
import resonantinduction.archaic.filter.imprint.TileFilterable;
|
import resonantinduction.archaic.filter.imprint.TileFilterable;
|
||||||
import universalelectricity.core.transform.vector.Vector3;
|
import universalelectricity.core.transform.vector.Vector3;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
|
||||||
|
|
||||||
/** @author Darkguardsman */
|
/** @author Darkguardsman */
|
||||||
public class TileRejector extends TileFilterable implements IPacketReceiverWithID
|
public class TileRejector extends TileFilterable implements IPacketIDReceiver
|
||||||
{
|
{
|
||||||
/** should the piston fire, or be extended */
|
/** should the piston fire, or be extended */
|
||||||
public boolean firePiston = false;
|
public boolean firePiston = false;
|
||||||
|
@ -28,7 +29,8 @@ public class TileRejector extends TileFilterable implements IPacketReceiverWithI
|
||||||
public TileRejector()
|
public TileRejector()
|
||||||
{
|
{
|
||||||
super(Material.circuits);
|
super(Material.circuits);
|
||||||
this.set
|
this.isOpaqueCube(false);
|
||||||
|
this.normalRender(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,11 +106,11 @@ public class TileRejector extends TileFilterable implements IPacketReceiverWithI
|
||||||
@Override
|
@Override
|
||||||
public Packet getDescriptionPacket()
|
public Packet getDescriptionPacket()
|
||||||
{
|
{
|
||||||
return ResonantInduction.PACKET_TILE.getPacket(this, 0, this.isInverted(), this.firePiston);
|
return ResonantEngine.instance.packetHandler.toMCPacket(new PacketTile(this, 0, this.isInverted(), this.firePiston));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
public boolean read(ByteBuf data, int id, EntityPlayer player, PacketType type)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,276 +0,0 @@
|
||||||
package resonantinduction.mechanical.logistic.belt;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
|
||||||
import net.minecraftforge.client.model.IModelCustom;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import resonant.lib.content.module.TileRender;
|
|
||||||
import resonant.lib.content.module.prefab.TileInventory;
|
|
||||||
import resonant.lib.network.Synced.SyncedInput;
|
|
||||||
import resonant.lib.network.Synced.SyncedOutput;
|
|
||||||
import resonant.lib.prefab.vector.Cuboid;
|
|
||||||
import resonant.lib.render.RenderUtility;
|
|
||||||
import resonant.lib.utility.inventory.InventoryUtility;
|
|
||||||
import resonantinduction.core.Reference;
|
|
||||||
import resonantinduction.archaic.filter.imprint.ItemImprint;
|
|
||||||
import universalelectricity.api.UniversalElectricity;
|
|
||||||
import universalelectricity.core.transform.vector.Vector3;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
public class TileSorter extends TileInventory
|
|
||||||
{
|
|
||||||
private boolean isInverted = false;
|
|
||||||
|
|
||||||
public TileSorter()
|
|
||||||
{
|
|
||||||
super(UniversalElectricity.machine);
|
|
||||||
textureName = "material_metal_side";
|
|
||||||
maxSlots = 12;
|
|
||||||
normalRender = false;
|
|
||||||
isOpaqueCube = false;
|
|
||||||
bounds = Cuboid.full().expand(-0.01);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean use(EntityPlayer player, int side, Vector3 vector3)
|
|
||||||
{
|
|
||||||
return interactCurrentItem(side, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean configure(EntityPlayer player, int side, Vector3 vector3)
|
|
||||||
{
|
|
||||||
isInverted = !isInverted;
|
|
||||||
|
|
||||||
if (world().isRemote)
|
|
||||||
{
|
|
||||||
player.addChatMessage("Sorter filter inversion: " + !isInverted);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValidForSlot(int slot, ItemStack stack)
|
|
||||||
{
|
|
||||||
if (slot < 6)
|
|
||||||
return stack.getItem() instanceof ItemImprint;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void collide(Entity entity)
|
|
||||||
{
|
|
||||||
if (!world().isRemote)
|
|
||||||
{
|
|
||||||
if (entity instanceof EntityItem)
|
|
||||||
{
|
|
||||||
EntityItem entityItem = (EntityItem) entity;
|
|
||||||
sortItem(entityItem.getEntityItem());
|
|
||||||
entityItem.setDead();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlot(int i)
|
|
||||||
{
|
|
||||||
if (i < 6)
|
|
||||||
return this.getInventory().getStackInSlot(i);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInventorySlotContents(int i, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
if (i >= 6)
|
|
||||||
{
|
|
||||||
if (itemStack != null)
|
|
||||||
sortItem(itemStack);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
super.setInventorySlotContents(i, itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sortItem(ItemStack sortStack)
|
|
||||||
{
|
|
||||||
List<ForgeDirection> possibleDirections = new ArrayList<ForgeDirection>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Move item to position where a filter allows it.
|
|
||||||
*/
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
ItemStack stack = getStackInSlot(i);
|
|
||||||
|
|
||||||
if (!isInverted == ItemImprint.isFiltering(stack, sortStack))
|
|
||||||
{
|
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
|
||||||
|
|
||||||
int blockID = position().add(dir).getBlock(world());
|
|
||||||
Block block = Block.blocksList[blockID];
|
|
||||||
|
|
||||||
if (block == null || !Block.isNormalCube(blockID))
|
|
||||||
{
|
|
||||||
possibleDirections.add(dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (possibleDirections.size() == 0)
|
|
||||||
{
|
|
||||||
List<ForgeDirection> inventoryDirections = new ArrayList<ForgeDirection>();
|
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
|
||||||
|
|
||||||
int blockID = position().add(dir).getBlock(world());
|
|
||||||
Block block = Block.blocksList[blockID];
|
|
||||||
|
|
||||||
if (block == null || !Block.isNormalCube(blockID))
|
|
||||||
{
|
|
||||||
possibleDirections.add(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (position().add(dir).getTileEntity(world()) instanceof IInventory)
|
|
||||||
{
|
|
||||||
inventoryDirections.add(dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inventoryDirections.size() > 0)
|
|
||||||
possibleDirections = inventoryDirections;
|
|
||||||
}
|
|
||||||
|
|
||||||
int size = possibleDirections.size();
|
|
||||||
|
|
||||||
ForgeDirection dir = possibleDirections.get(size > 1 ? world().rand.nextInt(size - 1) : 0);
|
|
||||||
|
|
||||||
Vector3 spawn = center().add(dir, 1);
|
|
||||||
|
|
||||||
TileEntity tile = spawn.getTileEntity(world());
|
|
||||||
ItemStack remain = sortStack;
|
|
||||||
|
|
||||||
if (tile instanceof IInventory)
|
|
||||||
remain = InventoryUtility.putStackInInventory((IInventory) tile, remain, dir.ordinal(), false);
|
|
||||||
|
|
||||||
if (remain != null)
|
|
||||||
{
|
|
||||||
if (!world().isRemote)
|
|
||||||
InventoryUtility.dropItemStack(world(), spawn, remain, 20, 0);
|
|
||||||
|
|
||||||
remain = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int[] getAccessibleSlotsFromSide(int side)
|
|
||||||
{
|
|
||||||
return new int[] { side + 6 };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Cuboid getSelectBounds()
|
|
||||||
{
|
|
||||||
return Cuboid.full();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SyncedInput
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.readFromNBT(nbt);
|
|
||||||
nbt.getBoolean("isInverted");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SyncedOutput
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.writeToNBT(nbt);
|
|
||||||
nbt.setBoolean("isInverted", isInverted);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
protected TileRender newRenderer()
|
|
||||||
{
|
|
||||||
return new TileRender()
|
|
||||||
{
|
|
||||||
final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "sorter.tcn");
|
|
||||||
final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "sorter.png");
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderStatic(RenderBlocks renderer, Vector3 position)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
RenderUtility.enableBlending();
|
|
||||||
GL11.glTranslated(position.x + 0.5, position.y + 0.5, position.z + 0.5);
|
|
||||||
RenderUtility.bind(TEXTURE);
|
|
||||||
|
|
||||||
if (!isItem)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < TileSorter.this.getSizeInventory(); i++)
|
|
||||||
{
|
|
||||||
if (TileSorter.this.getStackInSlot(i) != null)
|
|
||||||
{
|
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
|
|
||||||
if (dir.ordinal() == 0)
|
|
||||||
GL11.glRotatef(-90, 0, 0, 1);
|
|
||||||
|
|
||||||
if (dir.ordinal() == 1)
|
|
||||||
GL11.glRotatef(90, 0, 0, 1);
|
|
||||||
|
|
||||||
RenderUtility.rotateBlockBasedOnDirection(dir);
|
|
||||||
if (TileSorter.this.isInverted)
|
|
||||||
MODEL.renderOnly("portRed", "connector");
|
|
||||||
else
|
|
||||||
MODEL.renderOnly("portBlue", "connector");
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MODEL.renderAllExcept("portBlue", "portRed", "connector");
|
|
||||||
|
|
||||||
RenderUtility.disableBlending();
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue