Merge branch 'development'

This commit is contained in:
Calclavia 2014-06-25 13:52:12 -04:00
commit 959505258d
116 changed files with 3114 additions and 2337 deletions

View File

@ -14,9 +14,14 @@ Support
* Make sure you used the latest Versions even try dev versions.
* use Pastebin to make it easier and so we don't have to scroll down a giant wall of text.
Support
======
* Make sure you used the latest Versions even try dev versions.
* use Pastebin to make it easier and so we don't have to scroll down a giant wall of text.
### Artist
* Archadia
* CyanideX
### License
"Resonant Induction" is under the Calclavia Mod License: http://calclavia.com/license/cl
"Resonant Induction" is under the Calclavia Mod License: http://calclavia.com/calclavia-mod-license/

View File

@ -1,9 +1,13 @@
package resonantinduction.archaic;
import resonant.lib.render.item.GlobalItemRenderer;
import resonantinduction.archaic.fluid.tank.TileTank;
public class ClientProxy extends CommonProxy
{
@Override
public void preInit()
{
GlobalItemRenderer.register(Archaic.blockTank.blockID, TileTank.ItemRenderer.instance);
}
}

View File

@ -9,212 +9,211 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import resonant.lib.utility.LanguageUtility;
import resonantinduction.archaic.Archaic;
import resonantinduction.core.grid.fluid.TileFluidDistribution;
import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit;
import universalelectricity.api.energy.UnitDisplay.UnitPrefix;
import universalelectricity.api.vector.Vector3;
/** @author Darkguardsman */
/**
* @author Darkguardsman
*/
public class ItemBlockTank extends ItemBlock implements IFluidContainerItem
{
public ItemBlockTank(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
public ItemBlockTank(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
@Override
public int getMetadata(int damage)
{
return damage;
}
@Override
public int getMetadata(int damage)
{
return damage;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{
FluidStack fluid = getFluid(stack);
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
{
if (itemStack.getTagCompound() != null && itemStack.getTagCompound().hasKey("fluid"))
{
FluidStack fluid = getFluid(itemStack);
if (fluid != null)
{
list.add("Fluid: " + fluid.getFluid().getLocalizedName());
list.add("Volume: " + UnitDisplay.getDisplay(fluid.amount, Unit.LITER, UnitPrefix.MILLI));
}
}
}
if (fluid != null)
{
list.add("Fluid: " + fluid.getFluid().getLocalizedName());
list.add("Volume: " + UnitDisplay.getDisplay(fluid.amount, Unit.LITER, UnitPrefix.MILLI));
}
}
}
@Override
public int getItemStackLimit(ItemStack stack)
{
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{
return 1;
}
return this.maxStackSize;
}
@Override
public int getItemStackLimit(ItemStack stack)
{
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{
return 1;
}
return this.maxStackSize;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
String translation = LanguageUtility.getLocal(Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage());
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
String translation = LanguageUtility.getLocal(Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage());
if (translation == null || translation.isEmpty())
{
return Block.blocksList[this.getBlockID()].getUnlocalizedName();
}
if (translation == null || translation.isEmpty())
{
return Block.blocksList[this.getBlockID()].getUnlocalizedName();
}
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage();
}
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage();
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileFluidDistribution)
{
((TileFluidDistribution) tile).setSubID(stack.getItemDamage());
((TileFluidDistribution) tile).getInternalTank().fill(getFluid(stack), true);
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileFluidDistribution)
{
((TileFluidDistribution) tile).setSubID(stack.getItemDamage());
((TileFluidDistribution) tile).getInternalTank().fill(getFluid(stack), true);
}
return true;
}
}
return true;
}
return false;
}
return false;
}
@Override
public FluidStack getFluid(ItemStack container)
{
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("fluid"))
{
return null;
}
return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("fluid"));
}
@Override
public FluidStack getFluid(ItemStack container)
{
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("fluid"))
{
return null;
}
return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("fluid"));
}
@Override
public int getCapacity(ItemStack container)
{
return TileTank.VOLUME;
}
@Override
public int getCapacity(ItemStack container)
{
return TileTank.VOLUME;
}
@Override
public int fill(ItemStack container, FluidStack resource, boolean doFill)
{
if (resource == null)
{
return 0;
}
@Override
public int fill(ItemStack container, FluidStack resource, boolean doFill)
{
if (resource == null)
{
return 0;
}
if (!doFill)
{
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("fluid"))
{
return Math.min(getCapacity(container), resource.amount);
}
if (!doFill)
{
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("fluid"))
{
return Math.min(getCapacity(container), resource.amount);
}
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("fluid"));
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("fluid"));
if (stack == null)
{
return Math.min(getCapacity(container), resource.amount);
}
if (stack == null)
{
return Math.min(getCapacity(container), resource.amount);
}
if (!stack.isFluidEqual(resource))
{
return 0;
}
if (!stack.isFluidEqual(resource))
{
return 0;
}
return Math.min(getCapacity(container) - stack.amount, resource.amount);
}
return Math.min(getCapacity(container) - stack.amount, resource.amount);
}
if (container.stackTagCompound == null)
{
container.stackTagCompound = new NBTTagCompound();
}
if (container.stackTagCompound == null)
{
container.stackTagCompound = new NBTTagCompound();
}
if (!container.stackTagCompound.hasKey("fluid"))
{
NBTTagCompound fluidTag = resource.writeToNBT(new NBTTagCompound());
if (!container.stackTagCompound.hasKey("fluid"))
{
NBTTagCompound fluidTag = resource.writeToNBT(new NBTTagCompound());
if (getCapacity(container) < resource.amount)
{
fluidTag.setInteger("Amount", getCapacity(container));
container.stackTagCompound.setTag("fluid", fluidTag);
return getCapacity(container);
}
if (getCapacity(container) < resource.amount)
{
fluidTag.setInteger("Amount", getCapacity(container));
container.stackTagCompound.setTag("fluid", fluidTag);
return getCapacity(container);
}
container.stackTagCompound.setTag("fluid", fluidTag);
return resource.amount;
}
container.stackTagCompound.setTag("fluid", fluidTag);
return resource.amount;
}
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("fluid");
FluidStack stack = FluidStack.loadFluidStackFromNBT(fluidTag);
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("fluid");
FluidStack stack = FluidStack.loadFluidStackFromNBT(fluidTag);
if (!stack.isFluidEqual(resource))
{
return 0;
}
if (!stack.isFluidEqual(resource))
{
return 0;
}
int filled = getCapacity(container) - stack.amount;
if (resource.amount < filled)
{
stack.amount += resource.amount;
filled = resource.amount;
}
else
{
stack.amount = getCapacity(container);
}
int filled = getCapacity(container) - stack.amount;
if (resource.amount < filled)
{
stack.amount += resource.amount;
filled = resource.amount;
}
else
{
stack.amount = getCapacity(container);
}
container.stackTagCompound.setTag("fluid", stack.writeToNBT(fluidTag));
return filled;
}
container.stackTagCompound.setTag("fluid", stack.writeToNBT(fluidTag));
return filled;
}
@Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain)
{
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("fluid") || maxDrain == 0)
{
return null;
}
@Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain)
{
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("fluid") || maxDrain == 0)
{
return null;
}
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("fluid"));
if (stack == null)
{
return null;
}
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("fluid"));
if (stack == null)
{
return null;
}
int drained = Math.min(stack.amount, maxDrain);
if (doDrain)
{
if (maxDrain >= stack.amount)
{
container.stackTagCompound.removeTag("fluid");
int drained = Math.min(stack.amount, maxDrain);
if (doDrain)
{
if (maxDrain >= stack.amount)
{
container.stackTagCompound.removeTag("fluid");
if (container.stackTagCompound.hasNoTags())
{
container.stackTagCompound = null;
}
return stack;
}
if (container.stackTagCompound.hasNoTags())
{
container.stackTagCompound = null;
}
return stack;
}
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("fluid");
fluidTag.setInteger("Amount", fluidTag.getInteger("Amount") - maxDrain);
container.stackTagCompound.setTag("fluid", fluidTag);
}
stack.amount = drained;
return stack;
}
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("fluid");
fluidTag.setInteger("Amount", fluidTag.getInteger("Amount") - maxDrain);
container.stackTagCompound.setTag("fluid", fluidTag);
}
stack.amount = drained;
return stack;
}
}

View File

@ -1,10 +1,13 @@
package resonantinduction.archaic.fluid.tank;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.PriorityQueue;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
import resonant.lib.utility.FluidUtility;
import resonantinduction.core.grid.fluid.FluidDistributionetwork;
import resonantinduction.core.grid.fluid.IFluidDistribution;
@ -22,120 +25,97 @@ public class TankNetwork extends FluidDistributionetwork
@Override
public void update()
{
final FluidStack networkTankFluid = getTank().getFluid();
int lowestY = 255;
int highestY = 0;
int connectorCount = 0;
int totalFluid = networkTankFluid != null ? networkTankFluid.amount : 0;
final FluidStack networkTankFluid = getTank().getFluid();
int lowestY = 255, highestY = 0;
//If we only have one tank only fill one tank
if (getConnectors().size() > 0)
{
int totalFluid = networkTankFluid != null ? networkTankFluid.amount : 0;
if (getConnectors().size() > 0)
{
HashMap<Integer, Integer> heightCount = new HashMap();
PriorityQueue<IFluidDistribution> heightPriorityQueue = new PriorityQueue(1024, new Comparator()
{
@Override
public int compare(Object a, Object b)
{
if (networkTankFluid != null && networkTankFluid.getFluid().isGaseous())
return 0;
IFluidDistribution tank = ((IFluidDistribution) getConnectors().toArray()[0]);
if (getConnectors().size() == 1)
{
tank.getInternalTank().setFluid(networkTankFluid);
tank.onFluidChanged();
needsUpdate = false;
return;
}
if (networkTankFluid != null)
{
//If fluid is gaseous fill all tanks equally
if (networkTankFluid.getFluid().isGaseous())
{
connectorCount = this.getConnectors().size();
for (IFluidDistribution connector : this.getConnectors())
{
FluidStack input = networkTankFluid.copy();
input.amount = (totalFluid / connectorCount) + (totalFluid % connectorCount);
connector.getInternalTank().setFluid(null);
totalFluid -= connector.getInternalTank().fill(input, true);
connector.onFluidChanged();
TileEntity wa = (TileEntity) a;
TileEntity wb = (TileEntity) b;
return wa.yCoord - wb.yCoord;
}
});
if (connectorCount > 0)
connectorCount--;
}
}
else
{
HashMap<Integer, LinkedList<IFluidDistribution>> heightMap = new HashMap<Integer, LinkedList<IFluidDistribution>>();
for (IFluidDistribution connector : this.getConnectors())
{
if (connector instanceof TileEntity)
{
int yCoord = ((TileEntity) connector).yCoord;
//Build map of all tanks by their y level
for (IFluidDistribution connector : this.getConnectors())
{
if (connector instanceof TileEntity)
{
LinkedList<IFluidDistribution> list = new LinkedList<IFluidDistribution>();
int yCoord = ((TileEntity) connector).yCoord;
if (yCoord < lowestY)
{
lowestY = yCoord;
}
if (yCoord < lowestY)
{
lowestY = yCoord;
}
if (yCoord > highestY)
{
highestY = yCoord;
}
if (yCoord > highestY)
{
highestY = yCoord;
}
heightPriorityQueue.add(connector);
heightCount.put(yCoord, heightCount.containsKey(yCoord) ? heightCount.get(yCoord) + 1 : 1);
}
}
if (heightMap.containsKey(yCoord))
{
list = heightMap.get(yCoord);
}
list.add(connector);
heightMap.put(yCoord, list);
}
}
boolean didChange = false;
//Loop threw levels
for (int yLevel = lowestY; yLevel <= highestY; yLevel++)
{
if (heightMap.containsKey(yLevel))
{
connectorCount = heightMap.get(yLevel).size();
while (!heightPriorityQueue.isEmpty())
{
IFluidDistribution distributeNode = heightPriorityQueue.poll();
int yCoord = ((TileEntity) distributeNode).yCoord;
int connectorCount = heightCount.get(yCoord);
if (connectorCount <= 0)
continue;
//Loop threw tanks in each level
for (IFluidDistribution connector : heightMap.get(yLevel))
{
//If tank is empty clear internal and move on
if (totalFluid <= 0)
{
connector.getInternalTank().setFluid(null);
connector.onFluidChanged();
continue;
}
if (totalFluid <= 0)
{
distributeNode.getInternalTank().setFluid(null);
distributeNode.onFluidChanged();
continue;
}
FluidStack input = networkTankFluid.copy();
input.amount = (totalFluid / connectorCount) + (totalFluid % connectorCount);
connector.getInternalTank().setFluid(null);
totalFluid -= connector.getInternalTank().fill(input, true);
connector.onFluidChanged();
int fluidPer = totalFluid / connectorCount;
int deltaFluidAmount = fluidPer - distributeNode.getInternalTank().getFluidAmount();
if (connectorCount > 1)
connectorCount--;
int current = distributeNode.getInternalTank().getFluidAmount();
}
}
}
}
}
else
{
//In the cases the tank is empty just clear all tanks
//instead of doing additional logic that is wasting ticks
for (IFluidDistribution connector : this.getConnectors())
{
connector.getInternalTank().setFluid(null);
connector.onFluidChanged();
}
}
}
needsUpdate = false;
if (deltaFluidAmount > 0)
{
int filled = distributeNode.getInternalTank().fill(FluidUtility.getStack(networkTankFluid, deltaFluidAmount), false);
distributeNode.getInternalTank().fill(FluidUtility.getStack(networkTankFluid, deltaFluidAmount / 10), true);
totalFluid -= current + filled;
}
else
{
FluidStack drain = distributeNode.getInternalTank().drain(Math.abs(deltaFluidAmount), false);
distributeNode.getInternalTank().drain(Math.abs(deltaFluidAmount / 10), true);
if (drain != null)
totalFluid -= current - drain.amount;
}
if (deltaFluidAmount != 0)
didChange = true;
if (connectorCount > 1)
connectorCount--;
heightCount.put(yCoord, connectorCount);
distributeNode.onFluidChanged();
}
if (!didChange)
needsUpdate = false;
}
}
@Override

View File

@ -18,13 +18,13 @@ import net.minecraftforge.fluids.FluidTank;
import org.lwjgl.opengl.GL11;
import resonant.api.IRemovable.ISneakPickup;
import resonant.api.items.ISimpleItemRenderer;
import resonant.lib.content.module.TileBlock.IComparatorInputOverride;
import resonant.lib.content.module.TileRender;
import resonant.lib.render.FluidRenderUtility;
import resonant.lib.render.RenderUtility;
import resonant.lib.utility.FluidUtility;
import resonant.lib.utility.WorldUtility;
import resonant.lib.utility.inventory.InventoryUtility;
import resonant.lib.utility.render.RenderBlockUtility;
import resonantinduction.archaic.Archaic;
import resonantinduction.core.Reference;
@ -36,217 +36,262 @@ import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** Tile/Block class for basic Dynamic tanks
*
* @author Darkguardsman */
/**
* Tile/Block class for basic Dynamic tanks
*
* @author Darkguardsman
*/
public class TileTank extends TileFluidDistribution implements IComparatorInputOverride, ISneakPickup
{
public static final int VOLUME = 16;
public static final int VOLUME = 16;
public TileTank()
{
super(UniversalElectricity.machine, VOLUME * FluidContainerRegistry.BUCKET_VOLUME);
isOpaqueCube = false;
normalRender = false;
itemBlock = ItemBlockTank.class;
}
public TileTank()
{
super(UniversalElectricity.machine, VOLUME * FluidContainerRegistry.BUCKET_VOLUME);
isOpaqueCube = false;
normalRender = false;
itemBlock = ItemBlockTank.class;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side)
{
return access != null && block != null && access.getBlockId(x, y, z) != block.blockID;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side)
{
return access != null && block != null && access.getBlockId(x, y, z) != block.blockID;
}
@Override
protected boolean use(EntityPlayer player, int side, Vector3 vector3)
{
if (!world().isRemote)
{
return FluidUtility.playerActivatedFluidItem(world(), x(), y(), z(), player, side);
}
@Override
protected boolean use(EntityPlayer player, int side, Vector3 vector3)
{
if (!world().isRemote)
{
return FluidUtility.playerActivatedFluidItem(world(), x(), y(), z(), player, side);
}
return true;
}
return true;
}
@Override
public int getComparatorInputOverride(int side)
{
if (getNetwork().getTank().getFluid() != null)
{
return (int) (15 * ((double) getNetwork().getTank().getFluidAmount() / (double) getNetwork().getTank().getCapacity()));
}
return 0;
}
@Override
public int getComparatorInputOverride(int side)
{
if (getNetwork().getTank().getFluid() != null)
{
return (int) (15 * ((double) getNetwork().getTank().getFluidAmount() / (double) getNetwork().getTank().getCapacity()));
}
return 0;
}
@Override
public int getLightValue(IBlockAccess access)
{
if (getInternalTank().getFluid() != null)
{
return getInternalTank().getFluid().getFluid().getLuminosity();
}
return super.getLightValue(access);
}
@Override
public int getLightValue(IBlockAccess access)
{
if (getInternalTank().getFluid() != null)
{
return getInternalTank().getFluid().getFluid().getLuminosity();
}
return super.getLightValue(access);
}
@Override
public FluidDistributionetwork getNetwork()
{
if (this.network == null)
{
this.network = new TankNetwork();
this.network.addConnector(this);
}
return this.network;
}
@Override
public FluidDistributionetwork getNetwork()
{
if (this.network == null)
{
this.network = new TankNetwork();
this.network.addConnector(this);
}
return this.network;
}
@Override
public void setNetwork(FluidDistributionetwork network)
{
if (network instanceof TankNetwork)
{
this.network = network;
}
}
@Override
public void setNetwork(FluidDistributionetwork network)
{
if (network instanceof TankNetwork)
{
this.network = network;
}
}
@Override
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
{
if (!this.worldObj.isRemote)
{
if (tileEntity instanceof TileTank)
{
getNetwork().merge(((IFluidDistribution) tileEntity).getNetwork());
renderSides = WorldUtility.setEnableSide(renderSides, side, true);
connectedBlocks[side.ordinal()] = tileEntity;
}
}
}
@Override
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
{
if (!this.worldObj.isRemote)
{
if (tileEntity instanceof TileTank)
{
getNetwork().merge(((IFluidDistribution) tileEntity).getNetwork());
renderSides = WorldUtility.setEnableSide(renderSides, side, true);
connectedBlocks[side.ordinal()] = tileEntity;
}
}
}
@SideOnly(Side.CLIENT)
@Override
protected TileRender newRenderer()
{
return new TileRender()
{
@Override
public boolean renderStatic(RenderBlocks renderer, Vector3 position)
{
RenderBlockUtility.tessellateBlockWithConnectedTextures(renderSides, world(), x(), y(), z(), Archaic.blockTank, null, RenderUtility.getIcon(Reference.PREFIX + "tankEdge"));
return true;
}
@SideOnly(Side.CLIENT)
@Override
protected TileRender newRenderer()
{
return new TileRender()
{
@Override
public boolean renderStatic(RenderBlocks renderer, Vector3 position)
{
RenderBlockUtility.tessellateBlockWithConnectedTextures(renderSides, world(), x(), y(), z(), Archaic.blockTank, null, RenderUtility.getIcon(Reference.PREFIX + "tankEdge"));
return true;
}
public void renderTank(TileEntity tileEntity, double x, double y, double z, FluidStack fluid)
{
if (tileEntity.worldObj != null && tileEntity instanceof TileTank)
{
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
public void renderTank(TileEntity tileEntity, double x, double y, double z, FluidStack fluid)
{
if (tileEntity.worldObj != null && tileEntity instanceof TileTank)
{
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
if (fluid != null)
{
GL11.glPushMatrix();
if (fluid != null)
{
GL11.glPushMatrix();
if (!fluid.getFluid().isGaseous())
{
GL11.glScaled(0.99, 0.99, 0.99);
FluidTank tank = ((TileTank) tileEntity).getInternalTank();
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
if (!fluid.getFluid().isGaseous())
{
GL11.glScaled(0.99, 0.99, 0.99);
FluidTank tank = ((TileTank) tileEntity).getInternalTank();
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.EAST);
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.EAST);
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.WEST);
double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.WEST);
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
}
else
{
GL11.glTranslated(-0.5, -0.5, -0.5);
GL11.glScaled(0.99, 0.99, 0.99);
int capacity = tileEntity instanceof TileTank ? ((TileTank) tileEntity).getInternalTank().getCapacity() : fluid.amount;
double filledPercentage = (double) fluid.amount / (double) capacity;
double renderPercentage = fluid.getFluid().isGaseous() ? 1 : filledPercentage;
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.EAST);
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.EAST);
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.WEST);
double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.WEST);
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
}
else
{
GL11.glTranslated(-0.5, -0.5, -0.5);
GL11.glScaled(0.99, 0.99, 0.99);
int capacity = tileEntity instanceof TileTank ? ((TileTank) tileEntity).getInternalTank().getCapacity() : fluid.amount;
double filledPercentage = (double) fluid.amount / (double) capacity;
double renderPercentage = fluid.getFluid().isGaseous() ? 1 : filledPercentage;
int[] displayList = FluidRenderUtility.getFluidDisplayLists(fluid, tileEntity.worldObj, false);
int[] displayList = FluidRenderUtility.getFluidDisplayLists(fluid, tileEntity.worldObj, false);
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Color color = new Color(fluid.getFluid().getColor());
RenderUtility.enableBlending();
GL11.glColor4d(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, fluid.getFluid().isGaseous() ? filledPercentage : 1);
Color color = new Color(fluid.getFluid().getColor());
RenderUtility.enableBlending();
GL11.glColor4d(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, fluid.getFluid().isGaseous() ? filledPercentage : 1);
RenderUtility.bind(FluidRenderUtility.getFluidSheet(fluid));
GL11.glCallList(displayList[(int) (renderPercentage * (FluidRenderUtility.DISPLAY_STAGES - 1))]);
RenderUtility.disableBlending();
GL11.glPopAttrib();
}
RenderUtility.bind(FluidRenderUtility.getFluidSheet(fluid));
GL11.glCallList(displayList[(int) (renderPercentage * (FluidRenderUtility.DISPLAY_STAGES - 1))]);
RenderUtility.disableBlending();
GL11.glPopAttrib();
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
}
GL11.glPopMatrix();
}
}
@Override
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
{
renderTank(TileTank.this, position.x, position.y, position.z, getInternalTank().getFluid());
return false;
}
@Override
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
{
renderTank(TileTank.this, position.x, position.y, position.z, getInternalTank().getFluid());
return false;
}
};
}
@Override
public boolean renderItem(ItemStack itemStack)
{
GL11.glPushMatrix();
GL11.glTranslated(0.5, 0.5, 0.5);
RenderBlockUtility.tessellateBlockWithConnectedTextures(itemStack.getItemDamage(), Archaic.blockTank, null, RenderUtility.getIcon(Reference.PREFIX + "tankEdge"));
GL11.glPopMatrix();
public static class ItemRenderer implements ISimpleItemRenderer
{
public static ItemRenderer instance = new ItemRenderer();
GL11.glPushMatrix();
GL11.glTranslated(0, -0.1, 0);
public void renderTank(double x, double y, double z, FluidStack fluid, int capacity)
{
FluidTank tank = new FluidTank(fluid, capacity);
GL11.glPushMatrix();
FluidStack fluid = null;
GL11.glTranslated(0.02, 0.02, 0.02);
GL11.glScaled(0.92, 0.92, 0.92);
if (itemStack.getTagCompound() != null && itemStack.getTagCompound().hasKey("fluid"))
{
fluid = FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("fluid"));
}
if (fluid != null)
{
GL11.glPushMatrix();
renderTank(TileTank.this, 0, 0, 0, fluid);
GL11.glPopMatrix();
return true;
}
};
}
if (!fluid.getFluid().isGaseous())
{
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
FluidRenderUtility.renderFluidTesselation(tank, percentageFilled, percentageFilled, percentageFilled, percentageFilled);
}
else
{
double filledPercentage = (double) fluid.amount / (double) capacity;
@Override
public List<ItemStack> getRemovedItems(EntityPlayer entity)
{
List<ItemStack> drops = new ArrayList<ItemStack>();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
ItemStack itemStack = new ItemStack(Archaic.blockTank, 1, 0);
if (itemStack != null)
{
if (getInternalTank() != null && getInternalTank().getFluid() != null)
{
FluidStack stack = getInternalTank().getFluid();
Color color = new Color(fluid.getFluid().getColor());
RenderUtility.enableBlending();
GL11.glColor4d(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, fluid.getFluid().isGaseous() ? filledPercentage : 1);
if (stack != null)
{
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
drain(ForgeDirection.UNKNOWN, stack.amount, false);
itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound()));
}
}
drops.add(itemStack);
}
return drops;
}
RenderUtility.bind(FluidRenderUtility.getFluidSheet(fluid));
FluidRenderUtility.renderFluidTesselation(tank, 1, 1, 1, 1);
RenderUtility.disableBlending();
GL11.glPopAttrib();
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
@Override
public void renderInventoryItem(ItemStack itemStack)
{
GL11.glPushMatrix();
RenderBlockUtility.tessellateBlockWithConnectedTextures(itemStack.getItemDamage(), Archaic.blockTank, null, RenderUtility.getIcon(Reference.PREFIX + "tankEdge"));
GL11.glPopMatrix();
GL11.glPushMatrix();
if (itemStack.getTagCompound() != null && itemStack.getTagCompound().hasKey("fluid"))
{
renderTank(0, 0, 0, FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("fluid")), VOLUME * FluidContainerRegistry.BUCKET_VOLUME);
}
GL11.glPopMatrix();
}
}
@Override
public List<ItemStack> getRemovedItems(EntityPlayer entity)
{
List<ItemStack> drops = new ArrayList();
ItemStack itemStack = new ItemStack(Archaic.blockTank, 1, 0);
if (itemStack != null)
{
if (getInternalTank() != null && getInternalTank().getFluid() != null)
{
FluidStack stack = getInternalTank().getFluid();
if (stack != null)
{
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
drain(ForgeDirection.UNKNOWN, stack.amount, false);
itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound()));
}
}
drops.add(itemStack);
}
return drops;
}
}

View File

@ -29,7 +29,6 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.event.world.WorldEvent.Save;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
@ -53,40 +52,38 @@ import resonant.lib.prefab.ore.OreGenerator;
import resonant.lib.recipe.UniversalRecipe;
import resonant.lib.render.RenderUtility;
import resonant.lib.thermal.EventThermal.EventThermalUpdate;
import resonant.lib.utility.nbt.NBTUtility;
import resonantinduction.atomic.base.ItemCell;
import resonantinduction.atomic.fission.BlockUraniumOre;
import resonantinduction.atomic.fission.ItemBreederFuel;
import resonantinduction.atomic.fission.ItemFissileFuel;
import resonantinduction.atomic.fission.ItemRadioactive;
import resonantinduction.atomic.fission.ItemUranium;
import resonantinduction.atomic.fission.reactor.BlockToxicWaste;
import resonantinduction.atomic.fission.reactor.TileControlRod;
import resonantinduction.atomic.fission.reactor.TileReactorCell;
import resonantinduction.atomic.fusion.BlockPlasmaHeater;
import resonantinduction.atomic.fusion.TileElectromagnet;
import resonantinduction.atomic.fusion.TilePlasma;
import resonantinduction.atomic.fusion.TilePlasmaHeater;
import resonantinduction.atomic.particle.accelerator.BlockAccelerator;
import resonantinduction.atomic.particle.accelerator.EntityParticle;
import resonantinduction.atomic.particle.accelerator.ItemDarkMatter;
import resonantinduction.atomic.particle.accelerator.TileAccelerator;
import resonantinduction.atomic.particle.fulmination.FulminationHandler;
import resonantinduction.atomic.particle.fulmination.ItemAntimatter;
import resonantinduction.atomic.particle.fulmination.TileFulmination;
import resonantinduction.atomic.particle.quantum.TileQuantumAssembler;
import resonantinduction.atomic.process.BlockChemicalExtractor;
import resonantinduction.atomic.process.ItemHazmat;
import resonantinduction.atomic.process.TileChemicalExtractor;
import resonantinduction.atomic.process.fission.BlockCentrifuge;
import resonantinduction.atomic.process.fission.BlockNuclearBoiler;
import resonantinduction.atomic.process.fission.TileCentrifuge;
import resonantinduction.atomic.process.fission.TileNuclearBoiler;
import resonantinduction.atomic.process.sensor.TileSiren;
import resonantinduction.atomic.process.sensor.TileThermometer;
import resonantinduction.atomic.process.turbine.BlockElectricTurbine;
import resonantinduction.atomic.process.turbine.TileElectricTurbine;
import resonantinduction.atomic.process.turbine.TileFunnel;
import resonantinduction.atomic.blocks.BlockToxicWaste;
import resonantinduction.atomic.blocks.BlockUraniumOre;
import resonantinduction.atomic.blocks.TileElectromagnet;
import resonantinduction.atomic.blocks.TileSiren;
import resonantinduction.atomic.items.ItemAntimatter;
import resonantinduction.atomic.items.ItemBreederFuel;
import resonantinduction.atomic.items.ItemCell;
import resonantinduction.atomic.items.ItemDarkMatter;
import resonantinduction.atomic.items.ItemFissileFuel;
import resonantinduction.atomic.items.ItemHazmat;
import resonantinduction.atomic.items.ItemRadioactive;
import resonantinduction.atomic.items.ItemUranium;
import resonantinduction.atomic.machine.accelerator.EntityParticle;
import resonantinduction.atomic.machine.accelerator.TileAccelerator;
import resonantinduction.atomic.machine.boiler.BlockNuclearBoiler;
import resonantinduction.atomic.machine.boiler.TileNuclearBoiler;
import resonantinduction.atomic.machine.centrifuge.BlockCentrifuge;
import resonantinduction.atomic.machine.centrifuge.TileCentrifuge;
import resonantinduction.atomic.machine.extractor.BlockChemicalExtractor;
import resonantinduction.atomic.machine.extractor.TileChemicalExtractor;
import resonantinduction.atomic.machine.extractor.turbine.BlockElectricTurbine;
import resonantinduction.atomic.machine.extractor.turbine.TileElectricTurbine;
import resonantinduction.atomic.machine.extractor.turbine.TileFunnel;
import resonantinduction.atomic.machine.fulmination.FulminationHandler;
import resonantinduction.atomic.machine.fulmination.TileFulmination;
import resonantinduction.atomic.machine.plasma.BlockPlasmaHeater;
import resonantinduction.atomic.machine.plasma.TilePlasma;
import resonantinduction.atomic.machine.plasma.TilePlasmaHeater;
import resonantinduction.atomic.machine.quantum.TileQuantumAssembler;
import resonantinduction.atomic.machine.reactor.TileControlRod;
import resonantinduction.atomic.machine.reactor.TileReactorCell;
import resonantinduction.atomic.machine.thermometer.TileThermometer;
import resonantinduction.atomic.schematic.SchematicAccelerator;
import resonantinduction.atomic.schematic.SchematicBreedingReactor;
import resonantinduction.atomic.schematic.SchematicFissionReactor;
@ -305,7 +302,7 @@ public class Atomic
blockElectromagnet = contentRegistry.newBlock(TileElectromagnet.class);
blockSiren = contentRegistry.newBlock(TileSiren.class);
blockSteamFunnel = contentRegistry.newBlock(TileFunnel.class);
blockAccelerator = contentRegistry.createTile(BlockAccelerator.class, TileAccelerator.class);
blockAccelerator = contentRegistry.newBlock(TileAccelerator.class);
blockFulmination = contentRegistry.newBlock(TileFulmination.class);
blockQuantumAssembler = contentRegistry.newBlock(TileQuantumAssembler.class);
blockToxicWaste = contentRegistry.createBlock(BlockToxicWaste.class).setCreativeTab(null);

View File

@ -7,30 +7,30 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import resonant.lib.render.block.BlockRenderingHandler;
import resonantinduction.atomic.fission.reactor.GuiReactorCell;
import resonantinduction.atomic.fission.reactor.RenderReactorCell;
import resonantinduction.atomic.fission.reactor.TileReactorCell;
import resonantinduction.atomic.fusion.RenderPlasmaHeater;
import resonantinduction.atomic.fusion.TilePlasmaHeater;
import resonantinduction.atomic.particle.accelerator.EntityParticle;
import resonantinduction.atomic.particle.accelerator.GuiAccelerator;
import resonantinduction.atomic.particle.accelerator.RenderParticle;
import resonantinduction.atomic.particle.accelerator.TileAccelerator;
import resonantinduction.atomic.particle.quantum.GuiQuantumAssembler;
import resonantinduction.atomic.particle.quantum.TileQuantumAssembler;
import resonantinduction.atomic.process.RenderChemicalExtractor;
import resonantinduction.atomic.process.TileChemicalExtractor;
import resonantinduction.atomic.process.fission.GuiCentrifuge;
import resonantinduction.atomic.process.fission.GuiChemicalExtractor;
import resonantinduction.atomic.process.fission.GuiNuclearBoiler;
import resonantinduction.atomic.process.fission.RenderCentrifuge;
import resonantinduction.atomic.process.fission.RenderNuclearBoiler;
import resonantinduction.atomic.process.fission.TileCentrifuge;
import resonantinduction.atomic.process.fission.TileNuclearBoiler;
import resonantinduction.atomic.process.sensor.RenderThermometer;
import resonantinduction.atomic.process.sensor.TileThermometer;
import resonantinduction.atomic.process.turbine.RenderElectricTurbine;
import resonantinduction.atomic.process.turbine.TileElectricTurbine;
import resonantinduction.atomic.machine.accelerator.EntityParticle;
import resonantinduction.atomic.machine.accelerator.GuiAccelerator;
import resonantinduction.atomic.machine.accelerator.RenderParticle;
import resonantinduction.atomic.machine.accelerator.TileAccelerator;
import resonantinduction.atomic.machine.boiler.GuiChemicalExtractor;
import resonantinduction.atomic.machine.boiler.GuiNuclearBoiler;
import resonantinduction.atomic.machine.boiler.RenderNuclearBoiler;
import resonantinduction.atomic.machine.boiler.TileNuclearBoiler;
import resonantinduction.atomic.machine.centrifuge.GuiCentrifuge;
import resonantinduction.atomic.machine.centrifuge.RenderCentrifuge;
import resonantinduction.atomic.machine.centrifuge.TileCentrifuge;
import resonantinduction.atomic.machine.extractor.RenderChemicalExtractor;
import resonantinduction.atomic.machine.extractor.TileChemicalExtractor;
import resonantinduction.atomic.machine.extractor.turbine.RenderElectricTurbine;
import resonantinduction.atomic.machine.extractor.turbine.TileElectricTurbine;
import resonantinduction.atomic.machine.plasma.RenderPlasmaHeater;
import resonantinduction.atomic.machine.plasma.TilePlasmaHeater;
import resonantinduction.atomic.machine.quantum.GuiQuantumAssembler;
import resonantinduction.atomic.machine.quantum.TileQuantumAssembler;
import resonantinduction.atomic.machine.reactor.GuiReactorCell;
import resonantinduction.atomic.machine.reactor.RenderReactorCell;
import resonantinduction.atomic.machine.reactor.TileReactorCell;
import resonantinduction.atomic.machine.thermometer.RenderThermometer;
import resonantinduction.atomic.machine.thermometer.TileThermometer;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;

View File

@ -4,18 +4,18 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonant.lib.prefab.ProxyBase;
import resonantinduction.atomic.fission.reactor.ContainerReactorCell;
import resonantinduction.atomic.fission.reactor.TileReactorCell;
import resonantinduction.atomic.fusion.ContainerNuclearBoiler;
import resonantinduction.atomic.particle.accelerator.ContainerAccelerator;
import resonantinduction.atomic.particle.accelerator.TileAccelerator;
import resonantinduction.atomic.particle.quantum.ContainerQuantumAssembler;
import resonantinduction.atomic.particle.quantum.TileQuantumAssembler;
import resonantinduction.atomic.process.ContainerChemicalExtractor;
import resonantinduction.atomic.process.TileChemicalExtractor;
import resonantinduction.atomic.process.fission.ContainerCentrifuge;
import resonantinduction.atomic.process.fission.TileCentrifuge;
import resonantinduction.atomic.process.fission.TileNuclearBoiler;
import resonantinduction.atomic.machine.accelerator.ContainerAccelerator;
import resonantinduction.atomic.machine.accelerator.TileAccelerator;
import resonantinduction.atomic.machine.boiler.TileNuclearBoiler;
import resonantinduction.atomic.machine.centrifuge.ContainerCentrifuge;
import resonantinduction.atomic.machine.centrifuge.TileCentrifuge;
import resonantinduction.atomic.machine.extractor.ContainerChemicalExtractor;
import resonantinduction.atomic.machine.extractor.TileChemicalExtractor;
import resonantinduction.atomic.machine.plasma.ContainerNuclearBoiler;
import resonantinduction.atomic.machine.quantum.ContainerQuantumAssembler;
import resonantinduction.atomic.machine.quantum.TileQuantumAssembler;
import resonantinduction.atomic.machine.reactor.ContainerReactorCell;
import resonantinduction.atomic.machine.reactor.TileReactorCell;
public class CommonProxy extends ProxyBase
{

View File

@ -1,15 +0,0 @@
package resonantinduction.atomic.base;
import resonant.lib.prefab.item.ItemBase;
import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI;
public class ItemASBase extends ItemBase
{
/** Must be called while in mod init phase. */
public ItemASBase(int itemID, String name)
{
super(itemID);
}
}

View File

@ -1,51 +0,0 @@
package resonantinduction.atomic.base;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import resonant.lib.render.EnumColor;
import resonant.lib.utility.LanguageUtility;
import resonantinduction.atomic.Atomic;
public class ItemCell extends Item
{
public ItemCell(int itemID)
{
super(itemID);
setContainerItem(Atomic.itemCell);
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4)
{
String tooltip = LanguageUtility.getLocal(getUnlocalizedName(itemStack) + ".tooltip");
if (tooltip != null && tooltip.length() > 0)
{
if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
{
list.add(LanguageUtility.getLocal("tooltip.noShift").replace("%0", EnumColor.AQUA.toString()).replace("%1", EnumColor.GREY.toString()));
}
else
{
list.addAll(LanguageUtility.splitStringPerWord(tooltip, 5));
}
}
}
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
String localized = LanguageUtility.getLocal(getUnlocalizedName() + "." + itemstack.getItemDamage() + ".name");
if (localized != null && !localized.isEmpty())
{
return getUnlocalizedName() + "." + itemstack.getItemDamage();
}
return getUnlocalizedName();
}
}

View File

@ -1,21 +0,0 @@
package resonantinduction.atomic.base;
import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI;
import universalelectricity.api.UniversalClass;
import universalelectricity.api.item.IEnergyItem;
import universalelectricity.api.item.ItemElectric;
@UniversalClass
public abstract class ItemElectricAS extends ItemElectric implements IEnergyItem
{
public ItemElectricAS(int itemID, String name)
{
super(Settings.CONFIGURATION.getItem(name, itemID).getInt());
this.setUnlocalizedName(Reference.PREFIX + name);
this.setCreativeTab(TabRI.DEFAULT);
this.setTextureName(Reference.PREFIX + name);
}
}

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission.reactor;
package resonantinduction.atomic.blocks;
import java.util.Random;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission;
package resonantinduction.atomic.blocks;
import java.util.Random;
@ -29,7 +29,7 @@ public class BlockUraniumOre extends BlockRadioactive
this.canSpread = false;
this.radius = 1f;
this.amplifier = 0;
this.spawnParticle = false;
this.spawnParticle = true;
}
@Override

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fusion;
package resonantinduction.atomic.blocks;
import java.util.List;

View File

@ -1,6 +1,7 @@
package resonantinduction.atomic.process.sensor;
package resonantinduction.atomic.blocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonant.lib.content.module.TileBlock;
import resonantinduction.core.Reference;
@ -30,30 +31,26 @@ public class TileSiren extends TileBlock
@Override
public void updateEntity()
{
if (worldObj == null)
World world = worldObj;
if (world != null)
{
return;
}
int metadata = world.getBlockMetadata(x(), y(), z());
int metadata = worldObj.getBlockMetadata(x(), y(), z());
if (worldObj.getBlockPowerInput(x(), y(), z()) > 0)
{
float volume = 0.5f;
for (int i = 0; i < 6; i++)
if (world.getBlockPowerInput(x(), y(), z()) > 0)
{
Vector3 check = position().translate(ForgeDirection.getOrientation(i));
int blockID = check.getBlockID(worldObj);
if (blockID == blockID())
float volume = 0.5f;
for (int i = 0; i < 6; i++)
{
volume *= 1.5f;
Vector3 check = position().translate(ForgeDirection.getOrientation(i));
if (check.getBlockID(world) == blockID())
{
volume *= 1.5f;
}
}
}
worldObj.playSoundEffect(x(), y(), z(), Reference.PREFIX + "alarm", volume, 1f - 0.18f * (metadata / 15f));
scheduelTick(30);
world.playSoundEffect(x(), y(), z(), Reference.PREFIX + "alarm", volume, 1f - 0.18f * (metadata / 15f));
scheduelTick(30);
}
}
}

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.fulmination;
package resonantinduction.atomic.items;
import java.util.List;
@ -19,7 +19,6 @@ import resonant.api.explosion.IExplosion;
import resonant.lib.flag.FlagRegistry;
import resonant.lib.prefab.poison.PoisonRadiation;
import resonantinduction.atomic.Atomic;
import resonantinduction.atomic.base.ItemCell;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings;
@ -43,6 +42,8 @@ public class ItemAntimatter extends ItemCell
@Override
public void registerIcons(IconRegister iconRegister)
{
// Animated Icons
//ResonantInduction.LOGGER.info(this.getUnlocalizedName().replace("item.", "") + "_milligram");
this.itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", "") + "_milligram");
this.iconGram = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", "") + "_gram");
}
@ -74,7 +75,7 @@ public class ItemAntimatter extends ItemCell
}
@ForgeSubscribe
public void baoZhaEvent(ItemExpireEvent evt)
public void antimatterExpireEvent(ItemExpireEvent evt)
{
if (evt.entityItem != null)
{
@ -90,7 +91,7 @@ public class ItemAntimatter extends ItemCell
{
if (!FlagRegistry.getModFlag(FlagRegistry.DEFAULT_NAME).containsValue(evt.entityItem.worldObj, Atomic.BAN_ANTIMATTER_POWER, "true", new Vector3(evt.entityItem)))
{
IExplosion explosive = new BzFanWuSu(evt.entity.worldObj, evt.entityItem, evt.entityItem.posX, evt.entityItem.posY, evt.entityItem.posZ, 4, itemStack.getItemDamage());
IExplosion explosive = new AntimatterExposion(evt.entity.worldObj, evt.entityItem, evt.entityItem.posX, evt.entityItem.posY, evt.entityItem.posZ, 4, itemStack.getItemDamage());
MinecraftForge.EVENT_BUS.post(new DoExplosionEvent(evt.entityItem.worldObj, explosive));
evt.entityItem.worldObj.createExplosion(evt.entityItem, evt.entityItem.posX, evt.entityItem.posY, evt.entityItem.posZ, explosive.getRadius(), true);
ResonantInduction.LOGGER.fine("Antimatter cell detonated at: " + evt.entityItem.posX + ", " + evt.entityItem.posY + ", " + evt.entityItem.posZ);
@ -111,11 +112,11 @@ public class ItemAntimatter extends ItemCell
}
}
public static class BzFanWuSu extends Explosion implements IExplosion
public static class AntimatterExposion extends Explosion implements IExplosion
{
private int tier;
public BzFanWuSu(World par1World, Entity par2Entity, double x, double y, double z, float size, int tier)
public AntimatterExposion(World par1World, Entity par2Entity, double x, double y, double z, float size, int tier)
{
super(par1World, par2Entity, x, y, z, size + 2 * tier);
this.tier = tier;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission;
package resonantinduction.atomic.items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;

View File

@ -0,0 +1,45 @@
package resonantinduction.atomic.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import resonant.api.IReactor;
import resonant.lib.prefab.item.ItemTooltip;
import resonant.lib.utility.LanguageUtility;
import resonantinduction.atomic.Atomic;
public class ItemCell extends ItemTooltip
{
public ItemCell(int itemID)
{
super(itemID);
setContainerItem(Atomic.itemCell);
}
@Override
public boolean shouldPassSneakingClickToBlock(World world, int x, int y, int z)
{
return world.getBlockTileEntity(x, y, z) instanceof IReactor;
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", ""));
}
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
String localized = LanguageUtility.getLocal(getUnlocalizedName() + "." + itemstack.getItemDamage() + ".name");
if (localized != null && !localized.isEmpty())
{
return getUnlocalizedName() + "." + itemstack.getItemDamage();
}
return getUnlocalizedName();
}
}

View File

@ -0,0 +1,24 @@
package resonantinduction.atomic.items;
import resonantinduction.core.ResonantInduction;
import net.minecraft.client.renderer.texture.IconRegister;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** Strange matter cell */
public class ItemDarkMatter extends ItemCell
{
public ItemDarkMatter(int itemID)
{
super(itemID);
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister iconRegister)
{
// Animated Icon
this.itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", ""));
}
}

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission;
package resonantinduction.atomic.items;
import java.util.List;
@ -11,6 +11,7 @@ import net.minecraftforge.fluids.FluidStack;
import resonant.api.IReactor;
import resonant.api.IReactorComponent;
import resonantinduction.atomic.Atomic;
import resonantinduction.atomic.machine.reactor.TileReactorCell;
import resonantinduction.core.Settings;
import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side;
@ -22,7 +23,7 @@ public class ItemFissileFuel extends ItemRadioactive implements IReactorComponen
public static final int DECAY = 2500;
/** Temperature at which the fuel rod will begin to re-enrich itself. */
public static final int BREEDING_TEMP = 1200;
public static final int BREEDING_TEMP = 1100;
/** The energy in one KG of uranium is: 72PJ, 100TJ in one cell of uranium. */
public static final long ENERGY = 100000000000L;
@ -51,7 +52,7 @@ public class ItemFissileFuel extends ItemRadioactive implements IReactorComponen
TileEntity tile = checkPos.getTileEntity(worldObj);
// Check that the other reactors not only exist but also are running.
if (tile instanceof IReactor && ((IReactor) tile).getTemperature() > BREEDING_TEMP)
if (tile instanceof TileReactorCell && ((TileReactorCell) tile).getTemperature() > BREEDING_TEMP)
{
reactors++;
}
@ -61,12 +62,15 @@ public class ItemFissileFuel extends ItemRadioactive implements IReactorComponen
if (reactors >= 2)
{
// Begin the process of re-enriching the uranium rod but not consistently.
if (worldObj.rand.nextInt(1000) <= 100 && reactor.getTemperature() > BREEDING_TEMP)
// Note: The center reactor cell only needs to be half of breeding temperature for this to work.
if (worldObj.rand.nextInt(1000) <= 100 && reactor.getTemperature() > (BREEDING_TEMP / 2))
{
// Cells can regain a random amount of health per tick.
int healAmt = worldObj.rand.nextInt(5);
// Determine if this is a completely dead cell (creative menu fission rod is like this).
//System.out.println("[Atomic Science] [Reactor Cell] Breeding " + String.valueOf(healAmt) + " back into fissle rod. " + String.valueOf(itemStack.getItemDamage()) + " / " + String.valueOf(itemStack.getMaxDamage()));
itemStack.setItemDamage(Math.max(itemStack.getItemDamage() - healAmt, 0));
// System.out.println("[Atomic Science] [Reactor Cell] Breeding " + String.valueOf(healAmt) + " back into fissle rod. " + String.valueOf(itemStack.getItemDamage()) + " / " + String.valueOf(itemStack.getMaxDamage()));
}
}
else

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process;
package resonantinduction.atomic.items;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission;
package resonantinduction.atomic.items;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission;
package resonantinduction.atomic.items;
import java.util.List;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.accelerator;
package resonantinduction.atomic.machine.accelerator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;

View File

@ -1,7 +1,8 @@
package resonantinduction.atomic.particle.accelerator;
package resonantinduction.atomic.machine.accelerator;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.nbt.NBTTagCompound;
@ -51,9 +52,10 @@ public class EntityParticle extends Entity implements IEntityAdditionalSpawnData
this.movementDirection = dir;
}
public static boolean canRenderAcceleratedParticle(World world, Vector3 pos)
public static boolean canSpawnParticle(World world, Vector3 pos)
{
if (pos.getBlockID(world) != 0)
Block block = Block.blocksList[pos.getBlockID(world)];
if (block != null && !block.isAirBlock(world, pos.intX(), pos.intY(), pos.intZ()))
{
return false;
}
@ -178,7 +180,7 @@ public class EntityParticle extends Entity implements IEntityAdditionalSpawnData
this.lastTurn--;
/** Checks if the current block condition allows the particle to exist */
if (!canRenderAcceleratedParticle(this.worldObj, new Vector3(this)) || this.isCollided)
if (!canSpawnParticle(this.worldObj, new Vector3(this)) || this.isCollided)
{
explode();
return;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.accelerator;
package resonantinduction.atomic.machine.accelerator;
import net.minecraft.entity.player.InventoryPlayer;
import resonant.lib.gui.GuiContainerBase;
@ -29,7 +29,7 @@ public class GuiAccelerator extends GuiContainerBase
Vector3 position = new Vector3(this.tileEntity);
position.translate(this.tileEntity.getDirection().getOpposite());
if (!EntityParticle.canRenderAcceleratedParticle(this.tileEntity.worldObj, position))
if (!EntityParticle.canSpawnParticle(this.tileEntity.worldObj, position))
{
status = "\u00a74Fail to emit; try rotating.";
}

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.accelerator;
package resonantinduction.atomic.machine.accelerator;
import java.util.Random;

View File

@ -1,6 +1,7 @@
package resonantinduction.atomic.particle.accelerator;
package resonantinduction.atomic.machine.accelerator;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
@ -13,10 +14,12 @@ import resonant.api.IRotatable;
import resonant.lib.network.Synced;
import resonant.lib.prefab.tile.TileElectricalInventory;
import resonantinduction.atomic.Atomic;
import resonantinduction.atomic.particle.fulmination.ItemAntimatter;
import resonantinduction.atomic.items.ItemAntimatter;
import resonantinduction.atomic.items.ItemDarkMatter;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.electricity.IVoltageInput;
import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.energy.IEnergyInterface;
@ -56,6 +59,7 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
public TileAccelerator()
{
super(UniversalElectricity.machine);
energy = new EnergyStorageHandler(energyPerTick * 2, energyPerTick / 20);
maxSlots = 4;
antiMatterDensityMultiplyer = DENSITY_MULTIPLYER_DEFAULT;
@ -147,16 +151,16 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
// Creates a accelerated particle if one needs to exist (on world load for example or player login).
if (getStackInSlot(0) != null && lastSpawnTick >= 40)
{
Vector3 spawnAcceleratedParticle = new Vector3(this);
spawnAcceleratedParticle.translate(getDirection().getOpposite());
spawnAcceleratedParticle.translate(0.5f);
Vector3 spawn_vec = new Vector3(this);
spawn_vec.translate(getDirection().getOpposite());
spawn_vec.translate(0.5f);
// Only render the particle if container within the proper environment for it.
if (EntityParticle.canRenderAcceleratedParticle(worldObj, spawnAcceleratedParticle))
if (EntityParticle.canSpawnParticle(worldObj, spawn_vec))
{
// Spawn the particle.
totalEnergyConsumed = 0;
entityParticle = new EntityParticle(worldObj, spawnAcceleratedParticle, new Vector3(this), getDirection().getOpposite());
entityParticle = new EntityParticle(worldObj, spawn_vec, new Vector3(this), getDirection().getOpposite());
worldObj.spawnEntityInWorld(entityParticle);
// Grabs input block hardness if available, otherwise defaults are used.
@ -239,6 +243,16 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
lastSpawnTick++;
}
}
@Override
protected boolean use(EntityPlayer player, int side, Vector3 hit)
{
if (!world().isRemote)
{
player.openGui(Atomic.INSTANCE, 0, world(), x(), y(), z());
}
return true;
}
private void CalculateParticleDensity()
{

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.fission;
package resonantinduction.atomic.machine.boiler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;

View File

@ -1,10 +1,10 @@
package resonantinduction.atomic.process.fission;
package resonantinduction.atomic.machine.boiler;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import resonant.lib.gui.GuiContainerBase;
import resonantinduction.atomic.process.ContainerChemicalExtractor;
import resonantinduction.atomic.process.TileChemicalExtractor;
import resonantinduction.atomic.machine.extractor.ContainerChemicalExtractor;
import resonantinduction.atomic.machine.extractor.TileChemicalExtractor;
import universalelectricity.api.energy.UnitDisplay.Unit;
public class GuiChemicalExtractor extends GuiContainerBase

View File

@ -1,9 +1,9 @@
package resonantinduction.atomic.process.fission;
package resonantinduction.atomic.machine.boiler;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import resonant.lib.gui.GuiContainerBase;
import resonantinduction.atomic.fusion.ContainerNuclearBoiler;
import resonantinduction.atomic.machine.plasma.ContainerNuclearBoiler;
import universalelectricity.api.energy.UnitDisplay.Unit;
public class GuiNuclearBoiler extends GuiContainerBase

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.fission;
package resonantinduction.atomic.machine.boiler;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.fission;
package resonantinduction.atomic.machine.boiler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.fission;
package resonantinduction.atomic.machine.centrifuge;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.fission;
package resonantinduction.atomic.machine.centrifuge;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;

View File

@ -1,8 +1,9 @@
package resonantinduction.atomic.process.fission;
package resonantinduction.atomic.machine.centrifuge;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import resonant.lib.gui.GuiContainerBase;
import resonantinduction.atomic.machine.boiler.TileNuclearBoiler;
import universalelectricity.api.energy.UnitDisplay.Unit;
public class GuiCentrifuge extends GuiContainerBase

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.fission;
package resonantinduction.atomic.machine.centrifuge;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.fission;
package resonantinduction.atomic.machine.centrifuge;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process;
package resonantinduction.atomic.machine.extractor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process;
package resonantinduction.atomic.machine.extractor;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process;
package resonantinduction.atomic.machine.extractor;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process;
package resonantinduction.atomic.machine.extractor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process;
package resonantinduction.atomic.machine.extractor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.turbine;
package resonantinduction.atomic.machine.extractor.turbine;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.turbine;
package resonantinduction.atomic.machine.extractor.turbine;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.turbine;
package resonantinduction.atomic.machine.extractor.turbine;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
@ -41,11 +41,11 @@ public class TileElectricTurbine extends TileTurbine implements IBoilHandler
@Override
public void playSound()
{
if (this.worldObj.getWorldTime() % (Atomic.SECOND_IN_TICKS * 1.3F) == 0)
if (this.worldObj.getWorldTime() % Atomic.SECOND_IN_TICKS == 0)
{
double maxVelocity = (getMaxPower() / torque) * 4;
float percentage = angularVelocity * 4 / (float) maxVelocity;
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, Reference.PREFIX + "turbine", percentage, 1.0F);
float percentage = Math.max(angularVelocity * 4 / (float) maxVelocity, 1.0f);
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, Reference.PREFIX + "turbine", percentage, 1.0f);
}
}

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.turbine;
package resonantinduction.atomic.machine.extractor.turbine;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.fulmination;
package resonantinduction.atomic.machine.fulmination;
import java.util.ArrayList;
import java.util.HashSet;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.fulmination;
package resonantinduction.atomic.machine.fulmination;
import java.util.EnumSet;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fusion;
package resonantinduction.atomic.machine.plasma;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fusion;
package resonantinduction.atomic.machine.plasma;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@ -9,7 +9,7 @@ import resonant.lib.gui.ContainerBase;
import resonant.lib.prefab.slot.SlotEnergyItem;
import resonant.lib.prefab.slot.SlotSpecific;
import resonantinduction.atomic.Atomic;
import resonantinduction.atomic.process.fission.TileNuclearBoiler;
import resonantinduction.atomic.machine.boiler.TileNuclearBoiler;
/** Nuclear boiler container */
public class ContainerNuclearBoiler extends ContainerBase

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fusion;
package resonantinduction.atomic.machine.plasma;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fusion;
package resonantinduction.atomic.machine.plasma;
import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fusion;
package resonantinduction.atomic.machine.plasma;
import java.util.HashMap;
@ -29,7 +29,7 @@ import com.google.common.io.ByteArrayDataInput;
public class TilePlasmaHeater extends TileElectrical implements IPacketReceiver, ITagRender, IFluidHandler
{
public static long DIAN = 10000000000L;
public static long joules = 10000000000L;
@Config
public static int plasmaHeatAmount = 100;
@ -42,7 +42,7 @@ public class TilePlasmaHeater extends TileElectrical implements IPacketReceiver,
public TilePlasmaHeater()
{
energy = new EnergyStorageHandler(DIAN, DIAN / 20);
energy = new EnergyStorageHandler(joules, joules / 20);
}
@Override
@ -67,11 +67,14 @@ public class TilePlasmaHeater extends TileElectrical implements IPacketReceiver,
{
if (energy.checkExtract())
{
if (tankInputDeuterium.getFluidAmount() >= plasmaHeatAmount && tankInputTritium.getFluidAmount() >= plasmaHeatAmount)
// Creates plasma if there is enough Deuterium, Tritium AND Plasma output is not full.
if (tankInputDeuterium.getFluidAmount() >= plasmaHeatAmount &&
tankInputTritium.getFluidAmount() >= plasmaHeatAmount &&
tankOutput.getFluidAmount() < tankOutput.getCapacity())
{
tankInputDeuterium.drain(plasmaHeatAmount, true);
tankInputTritium.drain(plasmaHeatAmount, true);
tankOutput.fill(new FluidStack(Atomic.FLUID_PLASMA, plasmaHeatAmount), true);
tankOutput.fill(new FluidStack(Atomic.FLUID_PLASMA, tankOutput.getCapacity()), true);
energy.extractEnergy();
}
}

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.quantum;
package resonantinduction.atomic.machine.quantum;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.quantum;
package resonantinduction.atomic.machine.quantum;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.quantum;
package resonantinduction.atomic.machine.quantum;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.quantum;
package resonantinduction.atomic.machine.quantum;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission.reactor;
package resonantinduction.atomic.machine.reactor;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;

View File

@ -1,12 +1,12 @@
package resonantinduction.atomic.fission.reactor;
package resonantinduction.atomic.machine.reactor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import resonant.lib.gui.ContainerBase;
import resonant.lib.prefab.slot.SlotSpecific;
import resonantinduction.atomic.fission.ItemBreederFuel;
import resonantinduction.atomic.fission.ItemFissileFuel;
import resonantinduction.atomic.items.ItemBreederFuel;
import resonantinduction.atomic.items.ItemFissileFuel;
public class ContainerReactorCell extends ContainerBase
{

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission.reactor;
package resonantinduction.atomic.machine.reactor;
import java.util.List;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission.reactor;
package resonantinduction.atomic.machine.reactor;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission.reactor;
package resonantinduction.atomic.machine.reactor;
import net.minecraft.block.material.Material;
import resonant.lib.content.module.TileBlock;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission.reactor;
package resonantinduction.atomic.machine.reactor;
import java.util.ArrayList;
import java.util.List;
@ -38,7 +38,7 @@ import resonant.lib.thermal.ThermalPhysics;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.atomic.Atomic;
import resonantinduction.atomic.ReactorExplosion;
import resonantinduction.atomic.fusion.TilePlasma;
import resonantinduction.atomic.machine.plasma.TilePlasma;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import universalelectricity.api.UniversalElectricity;
@ -110,15 +110,9 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
{
TileReactorCell tile = getMultiBlock().get();
if (!player.isSneaking())
if (player.inventory.getCurrentItem() != null)
{
if (tile.getStackInSlot(0) != null)
{
InventoryUtility.dropItemStack(world(), new Vector3(player), tile.getStackInSlot(0), 0);
tile.setInventorySlotContents(0, null);
return true;
}
else if (player.inventory.getCurrentItem() != null)
if (tile.getStackInSlot(0) == null)
{
if (player.inventory.getCurrentItem().getItem() instanceof IReactorComponent)
{
@ -130,8 +124,16 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
}
}
}
player.openGui(Atomic.INSTANCE, 0, world(), tile.xCoord, tile.yCoord, tile.zCoord);
else if (player.isSneaking() && tile.getStackInSlot(0) != null)
{
InventoryUtility.dropItemStack(world(), new Vector3(player), tile.getStackInSlot(0), 0);
tile.setInventorySlotContents(0, null);
return true;
}
else
{
player.openGui(Atomic.INSTANCE, 0, world(), tile.xCoord, tile.yCoord, tile.zCoord);
}
}
return true;
@ -214,8 +216,7 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
{
if (worldObj.rand.nextFloat() > 0.65)
{
List<EntityLiving> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class,
AxisAlignedBB.getBoundingBox(xCoord - RADIUS * 2, yCoord - RADIUS * 2, zCoord - RADIUS * 2, xCoord + RADIUS * 2, yCoord + RADIUS * 2, zCoord + RADIUS * 2));
List<EntityLiving> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(xCoord - RADIUS * 2, yCoord - RADIUS * 2, zCoord - RADIUS * 2, xCoord + RADIUS * 2, yCoord + RADIUS * 2, zCoord + RADIUS * 2));
for (EntityLiving entity : entities)
{
@ -276,7 +277,7 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
previousTemperature = temperature;
//System.out.println("[Atomic Science] [Thermal Grid] Temperature: " + String.valueOf(previousTemperature));
}
if (previousTemperature >= MELTING_POINT && meltdownCounter < meltdownCounterMaximum)
{
shouldUpdate = true;
@ -290,7 +291,7 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
meltDown();
return;
}
// Reset meltdown ticker to give the reactor more of a 'goldilocks zone'.
if (previousTemperature < MELTING_POINT && meltdownCounter < meltdownCounterMaximum && meltdownCounter > 0)
{
@ -479,7 +480,7 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
{
// Turn the reactor cell into a block of lava to imply it melted.
this.worldObj.setBlock(Block.lavaStill.blockID, 0, this.xCoord, this.yCoord, this.zCoord, 3);
ReactorExplosion reactorExplosion = new ReactorExplosion(worldObj, null, xCoord, yCoord, zCoord, 9f);
reactorExplosion.doExplosionA();
reactorExplosion.doExplosionB(true);
@ -514,7 +515,8 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
return 1;
}
/** Returns true if automation can insert the given item in the given slot from the given side. Args: Slot, item, side */
/** Returns true if automation can insert the given item in the given slot from the given side.
* Args: Slot, item, side */
@Override
public boolean canInsertItem(int slot, ItemStack items, int side)
{
@ -583,8 +585,7 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from)
{
return new FluidTankInfo[]
{ tank.getInfo() };
return new FluidTankInfo[] { tank.getInfo() };
}
@Override

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission.reactor;
package resonantinduction.atomic.machine.reactor;
import java.util.ArrayList;
import java.util.HashSet;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.sensor;
package resonantinduction.atomic.machine.thermometer;
import java.util.List;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.sensor;
package resonantinduction.atomic.machine.thermometer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

View File

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.sensor;
package resonantinduction.atomic.machine.thermometer;
import java.util.ArrayList;

View File

@ -1,37 +0,0 @@
package resonantinduction.atomic.particle.accelerator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonant.lib.prefab.block.BlockRotatable;
import resonantinduction.atomic.Atomic;
import universalelectricity.api.UniversalElectricity;
/** Accelerator block */
public class BlockAccelerator extends BlockRotatable
{
public BlockAccelerator(int id)
{
super(id, UniversalElectricity.machine);
}
@Override
public boolean onMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
int metadata = par1World.getBlockMetadata(x, y, z);
if (!par1World.isRemote)
{
par5EntityPlayer.openGui(Atomic.INSTANCE, 0, par1World, x, y, z);
}
return true;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileAccelerator();
}
}

View File

@ -1,12 +0,0 @@
package resonantinduction.atomic.particle.accelerator;
import resonantinduction.atomic.base.ItemCell;
/** Strange matter cell */
public class ItemDarkMatter extends ItemCell
{
public ItemDarkMatter(int itemID)
{
super(itemID);
}
}

View File

@ -1,10 +1,11 @@
/**
*
*
*/
package resonantinduction.electrical.battery;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef;
import java.util.ArrayList;
import java.util.Arrays;
@ -21,14 +22,16 @@ import org.lwjgl.opengl.GL11;
import resonant.api.items.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility;
import resonant.lib.utility.WorldUtility;
import resonantinduction.core.Reference;
import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* TODO: Make this more efficient.
*
* @author Calclavia
*
*/
@SideOnly(Side.CLIENT)
public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleItemRenderer
@ -83,8 +86,8 @@ public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleI
int energyLevel = (int) Math.round(((double) tile.getEnergyHandler().getEnergy() / (double) TileBattery.getEnergyForTier(tile.getBlockMetadata())) * 8);
RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/battery.png");
List<String> disabledParts = new ArrayList<String>();
List<String> enabledParts = new ArrayList<String>();
List<String> disabledParts = new ArrayList();
List<String> enabledParts = new ArrayList();
for (ForgeDirection check : ForgeDirection.VALID_DIRECTIONS)
{
@ -128,6 +131,24 @@ public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleI
{
GL11.glPushMatrix();
RenderUtility.rotateBlockBasedOnDirection(check);
//TODO: Fix this horrible patch.
switch (check)
{
case NORTH:
glRotatef(0, 0, 1, 0);
break;
case SOUTH:
glRotatef(0, 0, 1, 0);
break;
case WEST:
glRotatef(-180, 0, 1, 0);
break;
case EAST:
glRotatef(180, 0, 1, 0);
break;
}
GL11.glRotatef(-90, 0, 1, 0);
int io = tile.getIO(check);

View File

@ -61,7 +61,8 @@ public class TileMotor extends TileElectrical implements IRotatable, INodeProvid
if (node != null)
{
node.update(0.05f);
node.update(0.05f);
if (!isInversed)
{
receiveMechanical();

View File

@ -17,6 +17,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import resonant.api.event.LaserEvent;
import resonant.api.event.LaserFiredPlayerEvent;
import resonant.lib.prefab.vector.RayTraceHelper;
import resonant.lib.type.Pair;
import resonantinduction.core.ResonantInduction;
@ -120,7 +121,7 @@ public class ItemMiningLaser extends ItemEnergyTool
if (hit != null)
{
LaserEvent event = new LaserEvent.LaserFiredPlayerEvent(player, hit, stack);
LaserEvent event = new LaserFiredPlayerEvent(player, hit, stack);
MinecraftForge.EVENT_BUS.post(event);
if (!player.worldObj.isRemote && !event.isCanceled())
{

View File

@ -1,125 +0,0 @@
package resonantinduction.electrical.laser.gun;
import java.awt.Color;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import resonant.api.event.LaserEvent;
import resonant.lib.prefab.vector.RayTraceHelper;
import resonant.lib.thermal.ThermalGrid;
import resonantinduction.core.ResonantInduction;
import universalelectricity.api.item.ItemElectric;
import universalelectricity.api.vector.IVector3;
import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorWorld;
/** Version of the mining laser that uses the thermal grid to melt blocks down
*
* @author DarkGuardsman */
public class ItemThermalLaser extends ItemElectric
{
long batterySize = 100000;
float wattPerShot = 1;
float damageToEntities = 3.3f;
int blockRange = 50;
int firingDelay = 5;
int breakTime = 15;
boolean createLava = true, setFire = true;
public ItemThermalLaser(int id)
{
super(id);
this.setUnlocalizedName("MiningLaser");
this.setMaxStackSize(1);
this.setCreativeTab(CreativeTabs.tabTools);
}
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.bow;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
//TODO change render of the laser too show it slowly over heat, when it over heats eg gets to max use damage the player, and tool
return 1000;
}
@Override
public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count)
{
if (count > 5)
{
Vec3 playerPosition = Vec3.createVectorHelper(player.posX, player.posY + player.getEyeHeight(), player.posZ);
Vec3 playerLook = RayTraceHelper.getLook(player, 1.0f);
Vec3 p = Vec3.createVectorHelper(playerPosition.xCoord + playerLook.xCoord, playerPosition.yCoord + playerLook.yCoord, playerPosition.zCoord + playerLook.zCoord);
Vec3 playerViewOffset = Vec3.createVectorHelper(playerPosition.xCoord + playerLook.xCoord * blockRange, playerPosition.yCoord + playerLook.yCoord * blockRange, playerPosition.zCoord + playerLook.zCoord * blockRange);
MovingObjectPosition hit = RayTraceHelper.do_rayTraceFromEntity(player, new Vector3().toVec3(), blockRange, true);
//TODO fix sound
if (hit != null)
{
LaserEvent event = new LaserEvent.LaserFiredPlayerEvent(player, hit, stack);
MinecraftForge.EVENT_BUS.post(event);
if (!player.worldObj.isRemote && !event.isCanceled())
{
if (hit.typeOfHit == EnumMovingObjectType.ENTITY && hit.entityHit != null)
{
//TODO re-implements laser damage source
DamageSource damageSource = DamageSource.causeMobDamage(player);
hit.entityHit.attackEntityFrom(damageSource, damageToEntities);
hit.entityHit.setFire(5);
}
else if (hit.typeOfHit == EnumMovingObjectType.TILE)
{
ThermalGrid.addTemperature(new VectorWorld(player.worldObj, hit.blockX, hit.blockY, hit.blockZ), 100f);
}
}
playerViewOffset = hit.hitVec;
}
//TODO make beam brighter the longer it has been used
//TODO adjust the laser for the end of the gun
float x = (float) (MathHelper.cos((float) (player.rotationYawHead * 0.0174532925)) * (-.4) - MathHelper.sin((float) (player.rotationYawHead * 0.0174532925)) * (-.1));
float z = (float) (MathHelper.sin((float) (player.rotationYawHead * 0.0174532925)) * (-.4) + MathHelper.cos((float) (player.rotationYawHead * 0.0174532925)) * (-.1));
ResonantInduction.proxy.renderBeam(player.worldObj, (IVector3) new Vector3(p).translate(new Vector3(x, -.25, z)), (IVector3) new Vector3(playerViewOffset), Color.ORANGE, 1);
ResonantInduction.proxy.renderBeam(player.worldObj, (IVector3) new Vector3(p).translate(new Vector3(x, -.45, z)), (IVector3) new Vector3(playerViewOffset), Color.ORANGE, 1);
}
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World par2World, EntityPlayer player)
{
if (player.capabilities.isCreativeMode || this.getEnergy(itemStack) > this.wattPerShot)
{
player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
}
return itemStack;
}
@Override
public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
return par1ItemStack;
}
@Override
public long getEnergyCapacity(ItemStack theItem)
{
return this.batterySize;
}
}

View File

@ -41,7 +41,7 @@ import resonantinduction.mechanical.process.crusher.TileMechanicalPiston;
import resonantinduction.mechanical.process.edit.TileBreaker;
import resonantinduction.mechanical.process.edit.TilePlacer;
import resonantinduction.mechanical.process.grinder.TileGrindingWheel;
import resonantinduction.mechanical.process.purifier.TileMixer;
import resonantinduction.mechanical.process.mixer.TileMixer;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;

View File

@ -17,379 +17,413 @@ import universalelectricity.api.vector.IVectorWorld;
import universalelectricity.api.vector.Vector3;
import codechicken.multipart.TMultiPart;
/** A mechanical node for mechanical energy.
*
* @author Calclavia, Darkguardsman */
/**
* A mechanical node for mechanical energy.
*
* @author Calclavia, Darkguardsman
*/
public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
{
/** Is debug enabled for the node */
public boolean doDebug = false;
/** Used to note that you should trigger a packet update for rotation */
public boolean markRotationUpdate = false;
/** Which section of debug is enabled */
public int debugCue = 0, maxDebugCue = 1, minDebugCue = 0;
public static final int UPDATE_DEBUG = 0, CONNECTION_DEBUG = 1;
/** Rotational Force */
public double torque = 0;
/** Rotational speed */
public double prevAngularVelocity, angularVelocity = 0;
/** Rotational acceleration */
public float acceleration = 2f;
/**
* Is debug enabled for the node
*/
public boolean doDebug = false;
/**
* Used to note that you should trigger a packet update for rotation
*/
public boolean markRotationUpdate = false;
public boolean markTorqueUpdate = false;
/**
* Which section of debug is enabled
*/
public int debugCue = 0, maxDebugCue = 1, minDebugCue = 0;
public static final int UPDATE_DEBUG = 0, CONNECTION_DEBUG = 1;
/**
* Rotational Force
*/
public double torque = 0, prevTorque;
/**
* Rotational speed
*/
public double prevAngularVelocity, angularVelocity = 0;
/**
* Rotational acceleration
*/
public float acceleration = 2f;
/** The current rotation of the mechanical node. */
public double renderAngle = 0, prev_angle = 0;
/** Limits the max distance an object can rotate in a single update */
protected double maxDeltaAngle = Math.toRadians(180);
/**
* The current rotation of the mechanical node.
*/
public double renderAngle = 0, prev_angle = 0;
/**
* Limits the max distance an object can rotate in a single update
*/
protected double maxDeltaAngle = Math.toRadians(180);
protected double load = 2;
protected byte connectionMap = Byte.parseByte("111111", 2);
protected double load = 2;
protected byte connectionMap = Byte.parseByte("111111", 2);
private double power = 0;
private INodeProvider parent;
private long ticks = 0;
private double power = 0;
private INodeProvider parent;
private long ticks = 0;
private final AbstractMap<MechanicalNode, ForgeDirection> connections = new WeakHashMap<MechanicalNode, ForgeDirection>();
private final AbstractMap<MechanicalNode, ForgeDirection> connections = new WeakHashMap<MechanicalNode, ForgeDirection>();
public MechanicalNode(INodeProvider parent)
{
this.setParent(parent);
}
public MechanicalNode(INodeProvider parent)
{
this.setParent(parent);
}
@Override
public MechanicalNode setLoad(double load)
{
this.load = load;
return this;
}
@Override
public MechanicalNode setLoad(double load)
{
this.load = load;
return this;
}
public MechanicalNode setConnection(byte connectionMap)
{
this.connectionMap = connectionMap;
return this;
}
public MechanicalNode setConnection(byte connectionMap)
{
this.connectionMap = connectionMap;
return this;
}
@Override
public double getRadius()
{
return 0.5;
}
@Override
public double getRadius()
{
return 0.5;
}
public void update()
{
update(0.05f);
}
public void update()
{
update(0.05f);
}
@Override
public void update(float deltaTime)
{
ticks++;
if (ticks >= Long.MAX_VALUE)
{
ticks = 1;
}
//temp, TODO find a better way to trigger this
if (ticks % 100 == 0)
{
this.recache();
}
//-----------------------------------
// Render Update
//-----------------------------------
@Override
public void update(float deltaTime)
{
ticks++;
if (ticks >= Long.MAX_VALUE)
{
ticks = 1;
}
//temp, TODO find a better way to trigger this
if (ticks % 100 == 0)
{
this.recache();
}
//-----------------------------------
// Render Update
//-----------------------------------
if (angularVelocity >= 0)
{
renderAngle += Math.min(angularVelocity, this.maxDeltaAngle) * deltaTime;
}
else
{
renderAngle += Math.max(angularVelocity, -this.maxDeltaAngle) * deltaTime;
}
if (angularVelocity >= 0)
{
renderAngle += Math.min(angularVelocity, this.maxDeltaAngle) * deltaTime;
}
else
{
renderAngle += Math.max(angularVelocity, -this.maxDeltaAngle) * deltaTime;
}
if (renderAngle % (Math.PI * 2) != renderAngle)
{
revolve();
renderAngle = renderAngle % (Math.PI * 2);
}
if (renderAngle % (Math.PI * 2) != renderAngle)
{
revolve();
renderAngle = renderAngle % (Math.PI * 2);
}
//-----------------------------------
// Server side Update
//-----------------------------------
if (world() != null && !world().isRemote)
{
final double acceleration = this.acceleration * deltaTime;
//-----------------------------------
// Server side Update
//-----------------------------------
if (world() != null && !world().isRemote)
{
final double acceleration = this.acceleration * deltaTime;
if (Math.abs(prevAngularVelocity - angularVelocity) > 0.01f)
{
prevAngularVelocity = angularVelocity;
markRotationUpdate = true;
}
if (Math.abs(prevAngularVelocity - angularVelocity) > 0.01f)
{
prevAngularVelocity = angularVelocity;
markRotationUpdate = true;
}
//-----------------------------------
// Loss calculations
//-----------------------------------
double torqueLoss = Math.min(Math.abs(getTorque()), (Math.abs(getTorque() * getTorqueLoad()) + getTorqueLoad() / 10) * deltaTime);
if (Math.abs(prevTorque - torque) > 0.01f)
{
prevTorque = torque;
markTorqueUpdate = true;
}
if (torque > 0)
{
torque -= torqueLoss;
}
else
{
torque += torqueLoss;
}
//-----------------------------------
// Loss calculations
//-----------------------------------
double torqueLoss = Math.min(Math.abs(getTorque()), (Math.abs(getTorque() * getTorqueLoad()) + getTorqueLoad() / 10) * deltaTime);
torque += torque > 0 ? -torqueLoss : torqueLoss;
double velocityLoss = Math.min(Math.abs(getAngularSpeed()), (Math.abs(getAngularSpeed() * getAngularVelocityLoad()) + getAngularVelocityLoad() / 10) * deltaTime);
double velocityLoss = Math.min(Math.abs(getAngularSpeed()), (Math.abs(getAngularSpeed() * getAngularVelocityLoad()) + getAngularVelocityLoad() / 10) * deltaTime);
angularVelocity += angularVelocity > 0 ? -velocityLoss : velocityLoss;
if (angularVelocity > 0)
{
angularVelocity -= velocityLoss;
}
else
{
angularVelocity += velocityLoss;
}
if (getEnergy() <= 0)
{
angularVelocity = torque = 0;
}
if (getEnergy() <= 0)
{
angularVelocity = torque = 0;
}
power = getEnergy() / deltaTime;
power = getEnergy() / deltaTime;
//-----------------------------------
// Connection application of force and speed
//-----------------------------------
synchronized (getConnections())
{
Iterator<Entry<MechanicalNode, ForgeDirection>> it = getConnections().entrySet().iterator();
//-----------------------------------
// Connection application of force and speed
//-----------------------------------
synchronized (getConnections())
{
Iterator<Entry<MechanicalNode, ForgeDirection>> it = getConnections().entrySet().iterator();
while (it.hasNext())
{
Entry<MechanicalNode, ForgeDirection> entry = it.next();
while (it.hasNext())
{
Entry<MechanicalNode, ForgeDirection> entry = it.next();
ForgeDirection dir = entry.getValue();
MechanicalNode adjacentMech = entry.getKey();
/** Calculate angular velocity and torque. */
float ratio = adjacentMech.getRatio(dir.getOpposite(), this) / getRatio(dir, adjacentMech);
boolean inverseRotation = inverseRotation(dir, adjacentMech) && adjacentMech.inverseRotation(dir.getOpposite(), this);
ForgeDirection dir = entry.getValue();
MechanicalNode adjacentMech = entry.getKey();
/** Calculate angular velocity and torque. */
float ratio = adjacentMech.getRatio(dir.getOpposite(), this) / getRatio(dir, adjacentMech);
boolean inverseRotation = inverseRotation(dir, adjacentMech) && adjacentMech.inverseRotation(dir.getOpposite(), this);
int inversion = inverseRotation ? -1 : 1;
int inversion = inverseRotation ? -1 : 1;
double targetTorque = inversion * adjacentMech.getTorque() / ratio;
double applyTorque = targetTorque * acceleration;
double targetTorque = inversion * adjacentMech.getTorque() / ratio;
double applyTorque = targetTorque * acceleration;
if (Math.abs(torque + applyTorque) < Math.abs(targetTorque))
{
torque += applyTorque;
}
else if (Math.abs(torque - applyTorque) > Math.abs(targetTorque))
{
torque -= applyTorque;
}
if (Math.abs(torque + applyTorque) < Math.abs(targetTorque))
{
torque += applyTorque;
}
else if (Math.abs(torque - applyTorque) > Math.abs(targetTorque))
{
torque -= applyTorque;
}
double targetVelocity = inversion * adjacentMech.getAngularSpeed() * ratio;
double applyVelocity = targetVelocity * acceleration;
double targetVelocity = inversion * adjacentMech.getAngularSpeed() * ratio;
double applyVelocity = targetVelocity * acceleration;
if (Math.abs(angularVelocity + applyVelocity) < Math.abs(targetVelocity))
{
angularVelocity += applyVelocity;
}
else if (Math.abs(angularVelocity - applyVelocity) > Math.abs(targetVelocity))
{
angularVelocity -= applyVelocity;
}
if (Math.abs(angularVelocity + applyVelocity) < Math.abs(targetVelocity))
{
angularVelocity += applyVelocity;
}
else if (Math.abs(angularVelocity - applyVelocity) > Math.abs(targetVelocity))
{
angularVelocity -= applyVelocity;
}
/** Set all current rotations */
// adjacentMech.angle = Math.abs(angle) * (adjacentMech.angle >= 0 ? 1 : -1);
}
}
}
/** Set all current rotations */
// adjacentMech.angle = Math.abs(angle) * (adjacentMech.angle >= 0 ? 1 : -1);
}
}
}
onUpdate();
prev_angle = renderAngle;
}
onUpdate();
prev_angle = renderAngle;
}
protected void onUpdate()
{
protected void onUpdate()
{
}
}
/**
* Called when one revolution is made.
*/
protected void revolve()
{
/** Called when one revolution is made. */
protected void revolve()
{
}
}
@Override
public void apply(Object source, double torque, double angularVelocity)
{
this.torque += torque;
this.angularVelocity += angularVelocity;
}
@Override
public void apply(Object source, double torque, double angularVelocity)
{
this.torque += torque;
this.angularVelocity += angularVelocity;
}
@Override
public double getTorque()
{
return angularVelocity != 0 ? torque : 0;
}
@Override
public double getTorque()
{
return angularVelocity != 0 ? torque : 0;
}
@Override
public double getAngularSpeed()
{
return torque != 0 ? angularVelocity : 0;
}
@Override
public double getAngularSpeed()
{
return torque != 0 ? angularVelocity : 0;
}
@Override
public float getRatio(ForgeDirection dir, IMechanicalNode with)
{
return 0.5f;
}
@Override
public float getRatio(ForgeDirection dir, IMechanicalNode with)
{
return 0.5f;
}
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
return true;
}
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
return true;
}
/**
* The energy percentage loss due to resistance in seconds.
*/
public double getTorqueLoad()
{
return load;
}
/** The energy percentage loss due to resistance in seconds. */
public double getTorqueLoad()
{
return load;
}
public double getAngularVelocityLoad()
{
return load;
}
public double getAngularVelocityLoad()
{
return load;
}
/**
* Checks to see if a connection is allowed from side and from a source
*/
public boolean canConnect(ForgeDirection from, Object source)
{
if (source instanceof MechanicalNode)
{
boolean flag = (connectionMap & (1 << from.ordinal())) != 0;
return flag;
}
return false;
}
/** Checks to see if a connection is allowed from side and from a source */
public boolean canConnect(ForgeDirection from, Object source)
{
if (source instanceof MechanicalNode)
{
boolean flag = (connectionMap & (1 << from.ordinal())) != 0;
return flag;
}
return false;
}
@Override
public double getEnergy()
{
return getTorque() * getAngularSpeed();
}
@Override
public double getEnergy()
{
return getTorque() * getAngularSpeed();
}
@Override
public double getPower()
{
return power;
}
@Override
public double getPower()
{
return power;
}
@Override
public void load(NBTTagCompound nbt)
{
torque = nbt.getDouble("torque");
angularVelocity = nbt.getDouble("angularVelocity");
}
@Override
public void load(NBTTagCompound nbt)
{
torque = nbt.getDouble("torque");
angularVelocity = nbt.getDouble("angularVelocity");
}
@Override
public void save(NBTTagCompound nbt)
{
nbt.setDouble("torque", torque);
nbt.setDouble("angularVelocity", angularVelocity);
}
@Override
public void save(NBTTagCompound nbt)
{
nbt.setDouble("torque", torque);
nbt.setDouble("angularVelocity", angularVelocity);
}
@Override
public void reconstruct()
{
recache();
}
@Override
public void reconstruct()
{
recache();
}
@Override
public void deconstruct()
{
for (Entry<MechanicalNode, ForgeDirection> entry : getConnections().entrySet())
{
entry.getKey().getConnections().remove(this);
entry.getKey().recache();
}
getConnections().clear();
}
@Override
public void deconstruct()
{
for (Entry<MechanicalNode, ForgeDirection> entry : getConnections().entrySet())
{
entry.getKey().getConnections().remove(this);
entry.getKey().recache();
}
getConnections().clear();
}
@Override
public void recache()
{
synchronized (this)
{
getConnections().clear();
@Override
public void recache()
{
getConnections().clear();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = position().translate(dir).getTileEntity(world());
if (tile instanceof INodeProvider)
{
INode node = ((INodeProvider) tile).getNode(MechanicalNode.class, dir.getOpposite());
if (node instanceof MechanicalNode)
{
MechanicalNode check = (MechanicalNode) node;
boolean canConnect = canConnect(dir, check);
boolean canOtherConnect = check.canConnect(dir.getOpposite(), this);
if (canConnect && canOtherConnect)
{
getConnections().put(check, dir);
}
}
}
}
}
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = position().translate(dir).getTileEntity(world());
if (tile instanceof INodeProvider)
{
INode node = ((INodeProvider) tile).getNode(MechanicalNode.class, dir.getOpposite());
if (node instanceof MechanicalNode)
{
MechanicalNode check = (MechanicalNode) node;
boolean canConnect = canConnect(dir, check);
boolean canOtherConnect = check.canConnect(dir.getOpposite(), this);
if (canConnect && canOtherConnect)
{
getConnections().put(check, dir);
}
}
}
}
}
/**
* Gets the node provider for this node
*/
public INodeProvider getParent()
{
return parent;
}
/** Gets the node provider for this node */
public INodeProvider getParent()
{
return parent;
}
/**
* Sets the node provider for the node
*/
public void setParent(INodeProvider parent)
{
this.parent = parent;
}
/** Sets the node provider for the node */
public void setParent(INodeProvider parent)
{
this.parent = parent;
}
@Override
public String toString()
{
return this.getClass().getSimpleName() + this.hashCode();
}
@Override
public String toString()
{
return this.getClass().getSimpleName() + this.hashCode();
}
public AbstractMap<MechanicalNode, ForgeDirection> getConnections()
{
return connections;
}
public AbstractMap<MechanicalNode, ForgeDirection> getConnections()
{
return connections;
}
@Override
public World world()
{
return getParent() instanceof TMultiPart ? ((TMultiPart) getParent()).world() : getParent() instanceof TileEntity ? ((TileEntity) getParent()).getWorldObj() : null;
}
@Override
public World world()
{
return getParent() instanceof TMultiPart ? ((TMultiPart) getParent()).world() : getParent() instanceof TileEntity ? ((TileEntity) getParent()).getWorldObj() : null;
}
public Vector3 position()
{
return new Vector3(x(), y(), z());
}
public Vector3 position()
{
return new Vector3(x(), y(), z());
}
@Override
public double z()
{
if (this.getParent() instanceof TileEntity)
{
return ((TileEntity) this.getParent()).zCoord;
}
return this.getParent() instanceof TMultiPart && ((TMultiPart) this.getParent()).tile() != null ? ((TMultiPart) this.getParent()).z() : 0;
}
@Override
public double z()
{
return this.getParent() instanceof TMultiPart && ((TMultiPart) this.getParent()).tile() != null ? ((TMultiPart) this.getParent()).z() : 0;
}
@Override
public double x()
{
if (this.getParent() instanceof TileEntity)
{
return ((TileEntity) this.getParent()).xCoord;
}
return this.getParent() instanceof TMultiPart && ((TMultiPart) this.getParent()).tile() != null ? ((TMultiPart) this.getParent()).x() : 0;
}
@Override
public double x()
{
return this.getParent() instanceof TMultiPart && ((TMultiPart) this.getParent()).tile() != null ? ((TMultiPart) this.getParent()).x() : 0;
}
@Override
public double y()
{
return this.getParent() instanceof TMultiPart && ((TMultiPart) this.getParent()).tile() != null ? ((TMultiPart) this.getParent()).y() : 0;
}
@Override
public double y()
{
if (this.getParent() instanceof TileEntity)
{
return ((TileEntity) this.getParent()).yCoord;
}
return this.getParent() instanceof TMultiPart && ((TMultiPart) this.getParent()).tile() != null ? ((TMultiPart) this.getParent()).y() : 0;
}
}

View File

@ -0,0 +1,173 @@
package resonantinduction.mechanical.energy.grid;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import javax.swing.AbstractListModel;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider;
import resonantinduction.core.debug.FrameNodeDebug;
import resonantinduction.core.debug.UpdatePanel;
import resonantinduction.core.debug.UpdatedLabel;
/** Java GUI used to help debug gear information
*
* @author Darkguardsman */
@SuppressWarnings("serial")
public class MechanicalNodeFrame extends FrameNodeDebug
{
JList<String> connectionList_component = null;
DefaultListModel<String> connectionList_model = new DefaultListModel<String>();;
public MechanicalNodeFrame(INodeProvider node)
{
super(node, MechanicalNode.class);
}
@Override
public void buildTop(UpdatePanel panel)
{
panel.setLayout(new GridLayout(1, 2, 0, 0));
UpdatedLabel tickLabel = new UpdatedLabel("Node: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + MechanicalNodeFrame.this.getNode();
}
};
panel.add(tickLabel);
UpdatedLabel xLabel = new UpdatedLabel("Parent: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + (MechanicalNodeFrame.this.getNode() != null ? MechanicalNodeFrame.this.getNode().getParent() : "null");
}
};
panel.add(xLabel);
}
@Override
public void buildCenter(UpdatePanel panel)
{
panel.setLayout(new BorderLayout());
TableModel dataModel = new AbstractTableModel()
{
@Override
public int getColumnCount()
{
return 4;
}
@Override
public String getColumnName(int column)
{
switch (column)
{
case 0:
return "Direction";
case 1:
return "Tile";
case 2:
return "Torque";
case 3:
return "Speed";
}
return "---";
}
@Override
public int getRowCount()
{
if (getNode() != null && getNode().getConnections() != null)
{
return getNode().getConnections().size();
}
return 10;
}
@Override
public Object getValueAt(int row, int col)
{
if (getNode() != null && getNode().getConnections() != null)
{
ForgeDirection dir = (ForgeDirection) getNode().getConnections().values().toArray()[row];
MechanicalNode node = (MechanicalNode) getNode().getConnections().keySet().toArray()[row];
switch(col)
{
case 0: return dir;
case 1: return node;
case 2: return node.getTorque();
case 3: return node.getAngularSpeed();
}
}
return "00000";
}
};
JTable table = new JTable(dataModel);
table.setAutoCreateRowSorter(true);
JScrollPane tableScroll = new JScrollPane(table);
Dimension tablePreferred = tableScroll.getPreferredSize();
tableScroll.setPreferredSize(new Dimension(tablePreferred.width, tablePreferred.height / 3));
panel.add(tableScroll, BorderLayout.SOUTH);
UpdatePanel topPanel = new UpdatePanel();
topPanel.setLayout(new GridLayout(1, 3, 0, 0));
UpdatedLabel velLabel = new UpdatedLabel("Vel: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + MechanicalNodeFrame.this.getNode().angularVelocity;
}
};
topPanel.add(velLabel);
UpdatedLabel angleLabel = new UpdatedLabel("Angle: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + MechanicalNodeFrame.this.getNode().renderAngle;
}
};
topPanel.add(angleLabel);
UpdatedLabel torqueLabel = new UpdatedLabel("Torque: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + MechanicalNodeFrame.this.getNode().torque;
}
};
topPanel.add(torqueLabel);
panel.add(topPanel, BorderLayout.NORTH);
}
@Override
public MechanicalNode getNode()
{
INode node = super.getNode();
if (node instanceof MechanicalNode)
{
return (MechanicalNode) node;
}
return null;
}
}

View File

@ -12,7 +12,6 @@ import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider;
import resonant.core.ResonantEngine;
import resonantinduction.mechanical.gear.GearDebugFrame;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.multipart.ControlKeyModifer;
@ -32,7 +31,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
/** Packets */
boolean markPacketUpdate = false;
/** Simple debug external GUI */
GearDebugFrame frame = null;
MechanicalNodeFrame frame = null;
/** Side of the block this is placed on */
public ForgeDirection placementSide = ForgeDirection.UNKNOWN;
@ -55,7 +54,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
}
//Make sure to update on both sides
this.node.update(0.05f);
this.node.update();
if (!world().isRemote)
{
@ -83,7 +82,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
//Opens a debug GUI
if (frame == null)
{
frame = new GearDebugFrame(this);
frame = new MechanicalNodeFrame(this);
frame.showDebugFrame();
} //Closes the debug GUI
else

View File

@ -1,29 +1,42 @@
package resonantinduction.mechanical.energy.grid;
import java.io.IOException;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider;
import resonant.core.ResonantEngine;
import resonant.lib.References;
import resonant.lib.content.module.TileBase;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.IPacketReceiverWithID;
import resonant.lib.network.PacketHandler;
import resonantinduction.core.ResonantInduction;
import resonantinduction.mechanical.Mechanical;
import universalelectricity.api.vector.Vector3;
import codechicken.multipart.ControlKeyModifer;
import com.google.common.io.ByteArrayDataInput;
/** Prefab for mechanical tiles
*
* @author Calclavia */
public abstract class TileMechanical extends TileBase implements INodeProvider, IPacketReceiver
public abstract class TileMechanical extends TileBase implements INodeProvider, IPacketReceiverWithID
{
protected static final int PACKET_VELOCITY = Mechanical.contentRegistry.getNextPacketID();
protected static final int PACKET_NBT = 0;
protected static final int PACKET_VELOCITY = 1;
/** Node that handles most mechanical actions */
public MechanicalNode mechanicalNode;
/** External debug GUI */
MechanicalNodeFrame frame = null;
@Deprecated
public TileMechanical()
@ -34,7 +47,7 @@ public abstract class TileMechanical extends TileBase implements INodeProvider,
public TileMechanical(Material material)
{
super(material);
mechanicalNode = new MechanicalNode(this).setLoad(0.5f);
this.mechanicalNode = new MechanicalNode(this);
}
@Override
@ -56,11 +69,58 @@ public abstract class TileMechanical extends TileBase implements INodeProvider,
{
super.updateEntity();
mechanicalNode.update();
if (mechanicalNode.markRotationUpdate && ticks % 10 == 0)
if(frame != null)
{
sendRotationPacket();
mechanicalNode.markRotationUpdate = false;
frame.update();
if(!frame.isVisible())
{
frame.dispose();
frame = null;
}
}
if (!this.getWorldObj().isRemote)
{
if (ticks % 3 == 0 && (mechanicalNode.markTorqueUpdate || mechanicalNode.markRotationUpdate))
{
//ResonantInduction.LOGGER.info("[mechanicalNode] Sending Update");
sendRotationPacket();
mechanicalNode.markRotationUpdate = false;
mechanicalNode.markTorqueUpdate = false;
}
}
}
@Override
protected boolean use(EntityPlayer player, int side, Vector3 hit)
{
ItemStack itemStack = player.getHeldItem();
if (ResonantEngine.runningAsDev)
{
if (itemStack != null && !world().isRemote)
{
if (itemStack.getItem().itemID == Item.stick.itemID)
{
//Set the nodes debug mode
if (ControlKeyModifer.isControlDown(player))
{
//Opens a debug GUI
if (frame == null)
{
frame = new MechanicalNodeFrame(this);
frame.showDebugFrame();
} //Closes the debug GUI
else
{
frame.closeDebugFrame();
frame = null;
}
}
}
}
}
return false;
}
@Override
@ -70,22 +130,46 @@ public abstract class TileMechanical extends TileBase implements INodeProvider,
return mechanicalNode;
return null;
}
@Override
public Packet getDescriptionPacket()
{
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return References.PACKET_TILE.getPacketWithID(PACKET_NBT, this, tag);
}
private void sendRotationPacket()
{
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, PACKET_VELOCITY, mechanicalNode.angularVelocity), worldObj, new Vector3(this), 20);
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_VELOCITY, this, mechanicalNode.angularVelocity, mechanicalNode.torque), worldObj, new Vector3(this), 20);
}
@Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
onReceivePacket(data.readInt(), data, player, extra);
}
public void onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
if (id == PACKET_VELOCITY)
mechanicalNode.angularVelocity = data.readDouble();
try
{
if (world().isRemote)
{
if (id == PACKET_NBT)
{
readFromNBT(PacketHandler.readNBTTagCompound(data));
return true;
}
else if (id == PACKET_VELOCITY)
{
mechanicalNode.angularVelocity = data.readDouble();
mechanicalNode.torque = data.readDouble();
return true;
}
}
}
catch (IOException e)
{
e.printStackTrace();
return true;
}
return false;
}
@Override

View File

@ -11,6 +11,7 @@ import org.lwjgl.opengl.GL11;
import resonant.api.items.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -30,13 +31,33 @@ public class RenderWaterTurbine extends TileEntitySpecialRenderer implements ISi
GL11.glTranslatef((float) x + 0.5f, (float) y + 0.5f, (float) z + 0.5f);
GL11.glPushMatrix();
// Determine if the turbine is facing horizontally or vertical.
RenderUtility.rotateBlockBasedOnDirectionUp(tile.getDirection());
GL11.glRotatef((float) Math.toDegrees(tile.mechanicalNode.renderAngle), 0, 1, 0);
// Get the rotation directly from the mechanical node running client side.
double mechanicalNodeRenderAngle = tile.mechanicalNode.renderAngle;
// We need to convert this value into something the model renderer can understand.
// Note: Check for NaN and if so then just defaults to zero.
float renderAngleInDegrees = 0;
if (!Double.isNaN(mechanicalNodeRenderAngle))
{
renderAngleInDegrees = (float) Math.toDegrees(mechanicalNodeRenderAngle);
}
// Call to actually rotate the gear model to the specified degree.
GL11.glRotatef(renderAngleInDegrees, 0, 1, 0);
//ResonantInduction.LOGGER.info("[RenderWaterTurbine] Render Angle: " + renderAngleInDegrees);
// Determine what type of water turbine model we need to use based on orientation.
if (tile.getDirection().offsetY != 0)
{
renderWaterTurbine(tile.tier, tile.multiBlockRadius, tile.getMultiBlock().isConstructed());
}
else
{
renderWaterWheel(tile.tier, tile.multiBlockRadius, tile.getMultiBlock().isConstructed());
}
GL11.glPopMatrix();
GL11.glPopMatrix();

View File

@ -32,7 +32,8 @@ public class RenderWindTurbine extends TileEntitySpecialRenderer implements ISim
RenderUtility.rotateBlockBasedOnDirectionUp(tile.getDirection());
GL11.glTranslatef(0, -0.35f, 0);
GL11.glTranslatef(0, 0.35f, 0);
GL11.glRotatef(180, 1, 0, 0);
GL11.glRotatef((float) Math.toDegrees(tile.mechanicalNode.renderAngle), 0, 1, 0);
render(tile.tier, tile.multiBlockRadius, tile.getMultiBlock().isConstructed());

View File

@ -1,35 +1,23 @@
package resonantinduction.mechanical.energy.turbine;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider;
import resonant.lib.References;
import resonant.lib.content.module.TileBase;
import resonant.lib.multiblock.IMultiBlockStructure;
import resonant.lib.network.IPacketReceiverWithID;
import resonant.lib.network.PacketHandler;
import resonant.lib.network.Synced;
import resonant.lib.network.Synced.SyncedInput;
import resonant.lib.network.Synced.SyncedOutput;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
import resonantinduction.mechanical.energy.grid.TileMechanical;
import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** Reduced version of the main turbine class */
public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTurbine>, INodeProvider, IPacketReceiverWithID
public class TileTurbine extends TileMechanical implements IMultiBlockStructure<TileTurbine>, INodeProvider, IPacketReceiverWithID
{
/** Tier of the tile */
public int tier = 0;
@ -43,10 +31,10 @@ public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTu
/** The power of the turbine this tick. In joules/tick */
public long power = 0;
protected final long defaultTorque = 5000;
protected double prevAngularVelocity = 0;
/** Node that handles most of the mechanical connections */
protected MechanicalNode mechanicalNode;
protected final long defaultTorque = 5000;
/** MutliBlock methods. */
private TurbineMBlockHandler multiBlock;
public TileTurbine()
{
@ -54,23 +42,10 @@ public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTu
mechanicalNode = new TurbineNode(this);
}
public ForgeDirection getDirection()
{
return ForgeDirection.getOrientation(getBlockMetadata());
}
@Override
public void initiate()
{
mechanicalNode.reconstruct();
super.initiate();
}
@Override
public void updateEntity()
{
super.updateEntity();
mechanicalNode.update();
getMultiBlock().update();
if (getMultiBlock().isPrimary())
@ -79,12 +54,6 @@ public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTu
{
/** Set angular velocity based on power and torque. */
mechanicalNode.angularVelocity = (float) ((double) power / mechanicalNode.torque);
if (ticks % 3 == 0 && prevAngularVelocity != mechanicalNode.angularVelocity)
{
sendPowerUpdate();
prevAngularVelocity = mechanicalNode.angularVelocity;
}
}
if (mechanicalNode.angularVelocity != 0)
@ -116,42 +85,25 @@ public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTu
public void playSound()
{
}
@Override
public Packet getDescriptionPacket()
{
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return References.PACKET_TILE.getPacketWithID(0, this, tag);
}
public void sendPowerUpdate()
{
References.PACKET_TILE.getPacketWithID(1, this, this.mechanicalNode.angularVelocity);
}
}
/** Reads a tile entity from NBT. */
@Override
@SyncedInput
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
multiBlockRadius = nbt.getInteger("multiBlockRadius");
tier = nbt.getInteger("tier");
mechanicalNode.load(nbt);
getMultiBlock().load(nbt);
}
/** Writes a tile entity to NBT. */
@Override
@SyncedOutput
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setInteger("multiBlockRadius", multiBlockRadius);
nbt.setInteger("tier", tier);
mechanicalNode.save(nbt);
getMultiBlock().save(nbt);
}
@ -162,9 +114,6 @@ public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTu
return AxisAlignedBB.getAABBPool().getAABB(this.xCoord - multiBlockRadius, this.yCoord - multiBlockRadius, this.zCoord - multiBlockRadius, this.xCoord + 1 + multiBlockRadius, this.yCoord + 1 + multiBlockRadius, this.zCoord + 1 + multiBlockRadius);
}
/** MutliBlock methods. */
private TurbineMBlockHandler multiBlock;
@Override
public Vector3[] getMultiBlockVectors()
{
@ -216,44 +165,4 @@ public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTu
{
return worldObj;
}
@Override
public INode getNode(Class<? extends INode> nodeType, ForgeDirection from)
{
if (nodeType.isAssignableFrom(mechanicalNode.getClass()))
return ((TileTurbine) getMultiBlock().get()).mechanicalNode;
return null;
}
@Override
public void invalidate()
{
mechanicalNode.deconstruct();
super.invalidate();
}
@Override
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
if (world().isRemote)
{
if (id == 0)
{
try
{
readFromNBT(PacketHandler.readNBTTagCompound(data));
}
catch (IOException e)
{
e.printStackTrace();
}
}
else if (id == 1)
{
this.mechanicalNode.angularVelocity = data.readDouble();
}
}
return false;
}
}

View File

@ -9,14 +9,15 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INodeProvider;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.ReflectionHelper;
/**
* The vertical wind turbine collects airflow.
* The horizontal wind turbine collects steam from steam power plants.
* The vertical water turbine collects flowing water flowing on X axis.
* The horizontal water turbine collects flowing water on Z axis.
*
* @author Calclavia
*
@ -56,9 +57,13 @@ public class TileWaterTurbine extends TileTurbine
public void updateEntity()
{
if (getMultiBlock().isConstructed())
{
mechanicalNode.torque = (long) (defaultTorque / (1d / multiBlockRadius));
}
else
{
mechanicalNode.torque = defaultTorque / 12;
}
/**
* If this is a horizontal turbine.
@ -108,12 +113,21 @@ public class TileWaterTurbine extends TileTurbine
Vector3 vector = new Vector3((Vec3) m.invoke(Block.waterMoving, worldObj, check.intX(), check.intY(), check.intZ()));
if ((currentDir.offsetZ > 0 && vector.x < 0) || (currentDir.offsetZ < 0 && vector.x > 0) || (currentDir.offsetX > 0 && vector.z > 0) || (currentDir.offsetX < 0 && vector.z < 0))
{
mechanicalNode.torque = -mechanicalNode.torque;
}
if (getDirection().offsetX != 0)
{
getMultiBlock().get().power += Math.abs(getWaterPower() * vector.z * (7 - metadata) / 7f);
powerTicks = 20;
}
if (getDirection().offsetZ != 0)
{
getMultiBlock().get().power += Math.abs(getWaterPower() * vector.x * (7 - metadata) / 7f);
powerTicks = 20;
}
}
catch (Exception e)
{

View File

@ -22,7 +22,6 @@ public class TileWindTurbine extends TileTurbine
private float efficiency = 0;
private long windPower = 0;
@Override
public void updateEntity()

View File

@ -4,36 +4,39 @@ import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.interfaces.IMechanicalNode;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
/** Turbine's Mechanical node
*
* @author Calclavia, Darkguardsman */
/**
* Turbine's Mechanical node
* Turbines always face forward and connect from behind.
*
* @author Calclavia, Darkguardsman
*/
public class TurbineNode extends MechanicalNode
{
public TurbineNode(TileTurbine tileTurbineBase)
{
super(tileTurbineBase);
}
public TurbineNode(TileTurbine tileTurbineBase)
{
super(tileTurbineBase);
}
public TileTurbine turbine()
{
return (TileTurbine) getParent();
}
public TileTurbine turbine()
{
return (TileTurbine) getParent();
}
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
return source instanceof MechanicalNode && !(source instanceof TurbineNode) && from == turbine().getDirection().getOpposite();
}
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
return turbine().getMultiBlock().isPrimary() && source instanceof MechanicalNode && !(source instanceof TurbineNode) && from == turbine().getDirection().getOpposite();
}
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
return dir == turbine().getDirection().getOpposite();
}
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
return dir == turbine().getDirection().getOpposite();
}
@Override
public float getRatio(ForgeDirection dir, IMechanicalNode with)
{
return turbine().getMultiBlock().isConstructed() ? turbine().multiBlockRadius - 0.5f : 0.5f;
}
@Override
public float getRatio(ForgeDirection dir, IMechanicalNode with)
{
return turbine().getMultiBlock().isConstructed() ? turbine().multiBlockRadius - 0.5f : 0.5f;
}
}

View File

@ -1,9 +1,12 @@
package resonantinduction.mechanical.fluid.pipe;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
@ -12,6 +15,7 @@ import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import resonant.api.grid.INode;
import resonant.core.ResonantEngine;
import resonant.lib.type.EvictingList;
import resonant.lib.utility.WorldUtility;
import resonantinduction.core.ResonantInduction;
@ -19,12 +23,14 @@ import resonantinduction.core.grid.fluid.FluidPressureNode;
import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import resonantinduction.core.prefab.part.PartFramedNode;
import resonantinduction.mechanical.Mechanical;
import resonantinduction.mechanical.energy.grid.MechanicalNodeFrame;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.IconTransformation;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.Translation;
import codechicken.microblock.IHollowConnect;
import codechicken.multipart.ControlKeyModifer;
import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.TSlottedPart;
import cpw.mods.fml.relauncher.Side;
@ -39,6 +45,7 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, FluidPressureNode
/** Computes the average fluid for client to render. */
private EvictingList<Integer> averageTankData = new EvictingList<Integer>(20);
private boolean markPacket = true;
private PipeNodeFrame frame = null;
public PartPipe()
{
@ -81,6 +88,11 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, FluidPressureNode
{
sendFluidUpdate();
markPacket = false;
}
if (frame != null)
{
frame.update();
}
}
@ -220,4 +232,44 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, FluidPressureNode
public void onFluidChanged()
{
}
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack itemStack)
{
if (ResonantEngine.runningAsDev)
{
if (itemStack != null && !world().isRemote)
{
if (itemStack.getItem().itemID == Item.stick.itemID)
{
//Set the nodes debug mode
if (ControlKeyModifer.isControlDown(player))
{
//Opens a debug GUI
if (frame == null)
{
frame = new PipeNodeFrame(this);
frame.showDebugFrame();
} //Closes the debug GUI
else
{
frame.closeDebugFrame();
frame = null;
}
}
}
}
}
return super.activate(player, hit, itemStack);
}
@Override
public void onWorldSeparate()
{
super.onWorldSeparate();
if (frame != null)
{
frame.closeDebugFrame();
}
}
}

View File

@ -0,0 +1,153 @@
package resonantinduction.mechanical.fluid.pipe;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider;
import resonantinduction.core.debug.FrameNodeDebug;
import resonantinduction.core.debug.UpdatePanel;
import resonantinduction.core.debug.UpdatedLabel;
/** Java GUI used to help debug pipe information
*
* @author Darkguardsman */
@SuppressWarnings("serial")
public class PipeNodeFrame extends FrameNodeDebug
{
public PipeNodeFrame(INodeProvider node)
{
super(node, PipePressureNode.class);
}
@Override
public void buildTop(UpdatePanel panel)
{
panel.setLayout(new GridLayout(1, 2, 0, 0));
UpdatedLabel tickLabel = new UpdatedLabel("Node: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + PipeNodeFrame.this.getNode();
}
};
panel.add(tickLabel);
UpdatedLabel xLabel = new UpdatedLabel("Parent: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + (PipeNodeFrame.this.getNode() != null ? PipeNodeFrame.this.getNode().pipe() : "null");
}
};
panel.add(xLabel);
}
@Override
public void buildCenter(UpdatePanel panel)
{
panel.setLayout(new BorderLayout());
TableModel dataModel = new AbstractTableModel()
{
@Override
public int getColumnCount()
{
return 3;
}
@Override
public String getColumnName(int column)
{
switch (column)
{
case 0:
return "Direction";
case 1:
return "Tile";
case 2:
return "Pressure";
}
return "---";
}
@Override
public int getRowCount()
{
if (getNode() != null && getNode().getConnections() != null)
{
return getNode().getConnections().size();
}
return 10;
}
@Override
public Object getValueAt(int row, int col)
{
if (getNode() != null && getNode().getConnections() != null)
{
ForgeDirection dir = (ForgeDirection) getNode().getConnections().values().toArray()[row];
switch (col)
{
case 0:
return dir;
case 1:
return getNode().getConnections().keySet().toArray()[row];
case 2:
return getNode().getPressure(dir);
}
}
return "00000";
}
};
JTable table = new JTable(dataModel);
table.setAutoCreateRowSorter(true);
JScrollPane tableScroll = new JScrollPane(table);
Dimension tablePreferred = tableScroll.getPreferredSize();
tableScroll.setPreferredSize(new Dimension(tablePreferred.width, tablePreferred.height / 3));
panel.add(tableScroll, BorderLayout.SOUTH);
UpdatePanel topPanel = new UpdatePanel();
topPanel.setLayout(new GridLayout(1, 2, 0, 0));
UpdatedLabel velLabel = new UpdatedLabel("Fluid: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + PipeNodeFrame.this.getNode().pipe().tank.getFluid();
}
};
topPanel.add(velLabel);
UpdatedLabel angleLabel = new UpdatedLabel("Volume: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + PipeNodeFrame.this.getNode().pipe().tank.getFluidAmount() + "mb";
}
};
topPanel.add(angleLabel);
panel.add(topPanel, BorderLayout.NORTH);
}
@Override
public PipePressureNode getNode()
{
INode node = super.getNode();
if (node instanceof PipePressureNode)
{
return (PipePressureNode) node;
}
return null;
}
}

View File

@ -103,4 +103,10 @@ public class PipePressureNode extends FluidPressureNode
return false;
}
@Override
public String toString()
{
return this.getClass().getSimpleName() + this.hashCode();
}
}

View File

@ -1,192 +0,0 @@
package resonantinduction.mechanical.gear;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
import resonantinduction.mechanical.energy.grid.PartMechanical;
/** Java GUI used to help debug gear information
*
* @author Darkguardsman */
@SuppressWarnings("serial")
public class GearDebugFrame extends Frame implements ActionListener
{
List<UpdatedLabel> dataLabels = new ArrayList<UpdatedLabel>();
Label[] connections = new Label[20];
long tick = 0;
PartMechanical part = null;
public GearDebugFrame(PartMechanical part)
{
this.part = part;
setLayout(new BorderLayout());
setBackground(Color.LIGHT_GRAY);
//Top bar
Panel topPanel = new Panel(new GridLayout(1, 4, 0, 0));
UpdatedLabel tickLabel = new UpdatedLabel("Tick: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + tick;
}
};
dataLabels.add(tickLabel);
topPanel.add(tickLabel);
UpdatedLabel xLabel = new UpdatedLabel("X: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + GearDebugFrame.this.part.x();
}
};
dataLabels.add(xLabel);
topPanel.add(xLabel);
UpdatedLabel yLabel = new UpdatedLabel("Y: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + GearDebugFrame.this.part.y();
}
};
topPanel.add(yLabel);
dataLabels.add(yLabel);
UpdatedLabel zLabel = new UpdatedLabel("Z: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + GearDebugFrame.this.part.z();
}
};
topPanel.add(zLabel);
dataLabels.add(zLabel);
add(topPanel, BorderLayout.NORTH);
//Middle bar
Panel middlePanel = new Panel(new GridLayout(3, 1, 0, 0));
UpdatedLabel velLabel = new UpdatedLabel("Vel: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + GearDebugFrame.this.part.node.angularVelocity;
}
};
dataLabels.add(velLabel);
middlePanel.add(velLabel);
UpdatedLabel angleLabel = new UpdatedLabel("Angle: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + GearDebugFrame.this.part.node.renderAngle;
}
};
dataLabels.add(angleLabel);
middlePanel.add(angleLabel);
UpdatedLabel torqueLabel = new UpdatedLabel("Torque: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + GearDebugFrame.this.part.node.torque;
}
};
dataLabels.add(torqueLabel);
middlePanel.add(torqueLabel);
add(middlePanel, BorderLayout.CENTER);
Panel connectionPanel = new Panel(new GridLayout(this.connections.length / 4, 4, 0, 0));
for (int i = 0; i < connections.length; i++)
{
this.connections[i] = new Label("Connection" + i + ": ----");
connectionPanel.add(connections[i]);
}
add(connectionPanel, BorderLayout.SOUTH);
//exit icon handler
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
Frame f = (Frame) e.getSource();
f.setVisible(false);
f.dispose();
}
});
}
/** Called each cpu cycle */
public void update()
{
tick++;
if (this.part != null)
{
for (UpdatedLabel label : dataLabels)
{
label.update();
}
int c = 0;
for (Entry<MechanicalNode, ForgeDirection> entry : part.node.getConnections().entrySet())
{
if (entry.getKey() != null)
{
this.connections[c].setText("Connection" + c + ": " + entry.getKey());
c++;
}
}
for (int i = c; i < connections.length; i++)
{
this.connections[i].setText("Connection" + i + ": NONE");
}
}
}
/** Shows the frame */
public void showDebugFrame()
{
setTitle("Resonant Engine Debug Window");
setBounds(200, 200, 450, 600);
setVisible(true);
}
/** Hides the frame and tells it to die off */
public void closeDebugFrame()
{
dispose();
}
@Override
public void actionPerformed(ActionEvent arg0)
{
// TODO Auto-generated method stub
}
}

View File

@ -10,283 +10,290 @@ import codechicken.lib.vec.Rotation;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
/** Node for the gear
*
* @author Calclavia, Edited by: Darkguardsman */
/**
* Node for the gear
*
* @author Calclavia, Edited by: Darkguardsman
*/
public class GearNode extends MechanicalNode
{
public GearNode(PartGear parent)
{
super(parent);
}
public GearNode(PartGear parent)
{
super(parent);
}
protected PartGear gear()
{
return (PartGear) this.getParent();
}
protected PartGear gear()
{
return (PartGear) this.getParent();
}
@Override
public void onUpdate()
{
super.onUpdate();
if (!gear().getMultiBlock().isPrimary())
{
torque = 0;
angularVelocity = 0;
}
else
{
if (gear().tier == 10)
{
torque = 100;
angularVelocity = 100;
}
}
}
@Override
public void onUpdate()
{
super.onUpdate();
if (!gear().getMultiBlock().isPrimary())
{
torque = 0;
angularVelocity = 0;
}
else
{
if (gear().tier == 10)
{
torque = 100;
angularVelocity = 100;
}
}
}
@Override
public double getTorqueLoad()
{
// Decelerate the gear based on tier.
switch (gear().tier)
{
default:
return 0.3;
case 1:
return 0.2;
case 2:
return 0.1;
case 10:
return 0;
}
}
@Override
public double getTorqueLoad()
{
// Decelerate the gear based on tier.
switch (gear().tier)
{
default:
return 0.3;
case 1:
return 0.2;
case 2:
return 0.1;
case 10:
return 0;
}
}
@Override
public double getAngularVelocityLoad()
{
// Decelerate the gear based on tier.
switch (gear().tier)
{
default:
return 0.03;
case 1:
return 0.02;
case 2:
return 0.01;
case 10:
return 0;
}
}
@Override
public double getAngularVelocityLoad()
{
// Decelerate the gear based on tier.
switch (gear().tier)
{
default:
return 0.03;
case 1:
return 0.02;
case 2:
return 0.01;
case 10:
return 0;
}
}
@Override
public void recache()
{
getConnections().clear();
@Override
public void recache()
{
synchronized (this)
{
getConnections().clear();
/** Only call refresh if this is the main block of a multiblock gear or a single gear block. */
if (!gear().getMultiBlock().isPrimary() || world() == null)
{
return;
}
/** Only call refresh if this is the main block of a multiblock gear or a single gear block. */
if (!gear().getMultiBlock().isPrimary() || world() == null)
{
return;
}
/** Look for gears that are back-to-back with this gear. Equate torque. */
TileEntity tileBehind = new universalelectricity.api.vector.Vector3(gear().tile()).translate(gear().placementSide).getTileEntity(world());
/** Look for gears that are back-to-back with this gear. Equate torque. */
TileEntity tileBehind = new universalelectricity.api.vector.Vector3(gear().tile()).translate(gear().placementSide).getTileEntity(world());
if (tileBehind instanceof INodeProvider)
{
MechanicalNode instance = (MechanicalNode) ((INodeProvider) tileBehind).getNode(MechanicalNode.class, gear().placementSide.getOpposite());
if (tileBehind instanceof INodeProvider)
{
MechanicalNode instance = (MechanicalNode) ((INodeProvider) tileBehind).getNode(MechanicalNode.class, gear().placementSide.getOpposite());
if (instance != null && instance != this && !(instance.getParent() instanceof PartGearShaft) && instance.canConnect(gear().placementSide.getOpposite(), this))
{
getConnections().put(instance, gear().placementSide);
}
}
if (instance != null && instance != this && !(instance.getParent() instanceof PartGearShaft) && instance.canConnect(gear().placementSide.getOpposite(), this))
{
getConnections().put(instance, gear().placementSide);
}
}
/** Look for gears that are internal and adjacent to this gear. (The 4 sides + the internal
* center) */
for (int i = 0; i < 6; i++)
{
ForgeDirection checkDir = ForgeDirection.getOrientation(i);
/** Look for gears that are internal and adjacent to this gear. (The 4 sides + the internal
* center) */
for (int i = 0; i < 6; i++)
{
ForgeDirection checkDir = ForgeDirection.getOrientation(i);
TileEntity tile = gear().tile();
TileEntity tile = gear().tile();
if (gear().getMultiBlock().isConstructed() && checkDir != gear().placementSide && checkDir != gear().placementSide.getOpposite())
{
tile = new universalelectricity.api.vector.Vector3(gear().tile()).translate(checkDir).getTileEntity(world());
}
if (gear().getMultiBlock().isConstructed() && checkDir != gear().placementSide && checkDir != gear().placementSide.getOpposite())
{
tile = new universalelectricity.api.vector.Vector3(gear().tile()).translate(checkDir).getTileEntity(world());
}
if (tile instanceof INodeProvider)
{
/** If we're checking for the block that is opposite to the gear's placement side
* (the center), then we try to look for a gear shaft in the center. */
MechanicalNode instance = (MechanicalNode) ((INodeProvider) tile).getNode(MechanicalNode.class, checkDir == gear().placementSide.getOpposite() ? ForgeDirection.UNKNOWN : checkDir);
if (tile instanceof INodeProvider)
{
/** If we're checking for the block that is opposite to the gear's placement side
* (the center), then we try to look for a gear shaft in the center. */
MechanicalNode instance = (MechanicalNode) ((INodeProvider) tile).getNode(MechanicalNode.class, checkDir == gear().placementSide.getOpposite() ? ForgeDirection.UNKNOWN : checkDir);
if (!getConnections().containsValue(checkDir) && instance != this && checkDir != gear().placementSide && instance != null && instance.canConnect(checkDir.getOpposite(), this))
{
getConnections().put(instance, checkDir);
}
}
}
if (!getConnections().containsValue(checkDir) && instance != this && checkDir != gear().placementSide && instance != null && instance.canConnect(checkDir.getOpposite(), this))
{
getConnections().put(instance, checkDir);
}
}
}
int displaceCheck = 1;
int displaceCheck = 1;
if (gear().getMultiBlock().isPrimary() && gear().getMultiBlock().isConstructed())
{
displaceCheck = 2;
}
if (gear().getMultiBlock().isPrimary() && gear().getMultiBlock().isConstructed())
{
displaceCheck = 2;
}
/** Look for gears outside this block space, the relative UP, DOWN, LEFT, RIGHT */
for (int i = 0; i < 4; i++)
{
ForgeDirection checkDir = ForgeDirection.getOrientation(Rotation.rotateSide(gear().placementSide.ordinal(), i));
TileEntity checkTile = new universalelectricity.api.vector.Vector3(gear().tile()).translate(checkDir, displaceCheck).getTileEntity(world());
/** Look for gears outside this block space, the relative UP, DOWN, LEFT, RIGHT */
for (int i = 0; i < 4; i++)
{
ForgeDirection checkDir = ForgeDirection.getOrientation(Rotation.rotateSide(gear().placementSide.ordinal(), i));
TileEntity checkTile = new universalelectricity.api.vector.Vector3(gear().tile()).translate(checkDir, displaceCheck).getTileEntity(world());
if (!getConnections().containsValue(checkDir) && checkTile instanceof INodeProvider)
{
MechanicalNode instance = (MechanicalNode) ((INodeProvider) checkTile).getNode(MechanicalNode.class, gear().placementSide);
if (!getConnections().containsValue(checkDir) && checkTile instanceof INodeProvider)
{
MechanicalNode instance = (MechanicalNode) ((INodeProvider) checkTile).getNode(MechanicalNode.class, gear().placementSide);
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this) && !(instance.getParent() instanceof PartGearShaft))
{
getConnections().put(instance, checkDir);
}
}
}
}
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this) && !(instance.getParent() instanceof PartGearShaft))
{
getConnections().put(instance, checkDir);
}
}
}
}
}
/** Can this gear be connected BY the source?
*
* @param from - Direction source is coming from.
* @param with - The source of the connection.
* @return True is so. */
@Override
public boolean canConnect(ForgeDirection from, Object with)
{
if (!gear().getMultiBlock().isPrimary())
{
return false;
}
/**
* Can this gear be connected BY the source?
*
* @param from - Direction source is coming from.
* @param with - The source of the connection.
* @return True is so.
*/
@Override
public boolean canConnect(ForgeDirection from, Object with)
{
if (!gear().getMultiBlock().isPrimary())
{
return false;
}
if (with instanceof MechanicalNode)
{
INodeProvider parent = ((MechanicalNode) with).getParent();
if (with instanceof MechanicalNode)
{
INodeProvider parent = ((MechanicalNode) with).getParent();
/** Check for flat connections (gear face on gear face) to make sure it's actually on
* this gear block. */
if (from == gear().placementSide.getOpposite())
{
if (parent instanceof PartGear || parent instanceof PartGearShaft)
{
if (parent instanceof PartGearShaft)
{
PartGearShaft shaft = (PartGearShaft) parent;
return shaft.tile().partMap(from.getOpposite().ordinal()) == gear() && Math.abs(shaft.placementSide.offsetX) == Math.abs(gear().placementSide.offsetX) && Math.abs(shaft.placementSide.offsetY) == Math.abs(gear().placementSide.offsetY) && Math.abs(shaft.placementSide.offsetZ) == Math.abs(gear().placementSide.offsetZ);
}
else if (parent instanceof PartGear)
{
if (((PartGear) parent).tile() == gear().tile() && !gear().getMultiBlock().isConstructed())
{
return true;
}
/** Check for flat connections (gear face on gear face) to make sure it's actually on
* this gear block. */
if (from == gear().placementSide.getOpposite())
{
if (parent instanceof PartGear || parent instanceof PartGearShaft)
{
if (parent instanceof PartGearShaft)
{
PartGearShaft shaft = (PartGearShaft) parent;
return shaft.tile().partMap(from.getOpposite().ordinal()) == gear() && Math.abs(shaft.placementSide.offsetX) == Math.abs(gear().placementSide.offsetX) && Math.abs(shaft.placementSide.offsetY) == Math.abs(gear().placementSide.offsetY) && Math.abs(shaft.placementSide.offsetZ) == Math.abs(gear().placementSide.offsetZ);
}
else if (parent instanceof PartGear)
{
if (((PartGear) parent).tile() == gear().tile() && !gear().getMultiBlock().isConstructed())
{
return true;
}
if (((PartGear) parent).placementSide != gear().placementSide)
{
TMultiPart part = gear().tile().partMap(((PartGear) parent).placementSide.ordinal());
if (((PartGear) parent).placementSide != gear().placementSide)
{
TMultiPart part = gear().tile().partMap(((PartGear) parent).placementSide.ordinal());
if (part instanceof PartGear)
{
/** Case when we connect gears via edges internally. Large gear
* attempt to connect to small gear. */
PartGear sourceGear = (PartGear) part;
if (part instanceof PartGear)
{
/** Case when we connect gears via edges internally. Large gear
* attempt to connect to small gear. */
PartGear sourceGear = (PartGear) part;
if (sourceGear.isCenterMultiBlock() && !sourceGear.getMultiBlock().isPrimary())
{
// For large gear to small gear on edge connection.
return true;
}
}
else
{
/** Small gear attempting to connect to large gear. */
if (gear().getMultiBlock().isConstructed())
{
TMultiPart checkPart = ((PartGear) parent).tile().partMap(gear().placementSide.ordinal());
if (sourceGear.isCenterMultiBlock() && !sourceGear.getMultiBlock().isPrimary())
{
// For large gear to small gear on edge connection.
return true;
}
}
else
{
/** Small gear attempting to connect to large gear. */
if (gear().getMultiBlock().isConstructed())
{
TMultiPart checkPart = ((PartGear) parent).tile().partMap(gear().placementSide.ordinal());
if (checkPart instanceof PartGear)
{
ForgeDirection requiredDirection = ((PartGear) checkPart).getPosition().subtract(position()).toForgeDirection();
return ((PartGear) checkPart).isCenterMultiBlock() && ((PartGear) parent).placementSide == requiredDirection;
}
}
}
}
}
}
if (checkPart instanceof PartGear)
{
ForgeDirection requiredDirection = ((PartGear) checkPart).getPosition().subtract(position()).toForgeDirection();
return ((PartGear) checkPart).isCenterMultiBlock() && ((PartGear) parent).placementSide == requiredDirection;
}
}
}
}
}
}
/** Face to face stick connection. */
TileEntity sourceTile = position().translate(from.getOpposite()).getTileEntity(world());
/** Face to face stick connection. */
TileEntity sourceTile = position().translate(from.getOpposite()).getTileEntity(world());
if (sourceTile instanceof INodeProvider)
{
MechanicalNode sourceInstance = (MechanicalNode) ((INodeProvider) sourceTile).getNode(MechanicalNode.class, from);
return sourceInstance == with;
}
}
else if (from == gear().placementSide)
{
/** Face to face stick connection. */
TileEntity sourceTile = position().translate(from).getTileEntity(world());
if (sourceTile instanceof INodeProvider)
{
MechanicalNode sourceInstance = (MechanicalNode) ((INodeProvider) sourceTile).getNode(MechanicalNode.class, from);
return sourceInstance == with;
}
}
else if (from == gear().placementSide)
{
/** Face to face stick connection. */
TileEntity sourceTile = position().translate(from).getTileEntity(world());
if (sourceTile instanceof INodeProvider)
{
MechanicalNode sourceInstance = (MechanicalNode) ((INodeProvider) sourceTile).getNode(MechanicalNode.class, from.getOpposite());
return sourceInstance == with;
}
}
else
{
TileEntity destinationTile = ((MechanicalNode) with).position().translate(from.getOpposite()).getTileEntity(world());
if (sourceTile instanceof INodeProvider)
{
MechanicalNode sourceInstance = (MechanicalNode) ((INodeProvider) sourceTile).getNode(MechanicalNode.class, from.getOpposite());
return sourceInstance == with;
}
}
else
{
TileEntity destinationTile = ((MechanicalNode) with).position().translate(from.getOpposite()).getTileEntity(world());
if (destinationTile instanceof INodeProvider && destinationTile instanceof TileMultipart)
{
TMultiPart destinationPart = ((TileMultipart) destinationTile).partMap(gear().placementSide.ordinal());
if (destinationTile instanceof INodeProvider && destinationTile instanceof TileMultipart)
{
TMultiPart destinationPart = ((TileMultipart) destinationTile).partMap(gear().placementSide.ordinal());
if (destinationPart instanceof PartGear)
{
if (gear() != destinationPart)
{
return ((PartGear) destinationPart).isCenterMultiBlock();
}
else
{
return true;
}
}
else
{
return true;
}
}
}
}
if (destinationPart instanceof PartGear)
{
if (gear() != destinationPart)
{
return ((PartGear) destinationPart).isCenterMultiBlock();
}
else
{
return true;
}
}
else
{
return true;
}
}
}
}
return false;
}
return false;
}
@Override
public float getRatio(ForgeDirection dir, IMechanicalNode with)
{
universalelectricity.api.vector.Vector3 deltaPos = with.position().subtract(position());
@Override
public float getRatio(ForgeDirection dir, IMechanicalNode with)
{
universalelectricity.api.vector.Vector3 deltaPos = with.position().subtract(position());
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 caseZ = gear().placementSide.offsetZ != 0 && deltaPos.x == 0 && deltaPos.y == 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 caseZ = gear().placementSide.offsetZ != 0 && deltaPos.x == 0 && deltaPos.y == 0;
if (caseX || caseY || caseZ)
{
return super.getRatio(dir, with);
}
if (caseX || caseY || caseZ)
{
return super.getRatio(dir, with);
}
return gear().getMultiBlock().isConstructed() ? 1.5f : super.getRatio(dir, with);
}
return gear().getMultiBlock().isConstructed() ? 1.5f : super.getRatio(dir, with);
}
}

View File

@ -10,116 +10,120 @@ import resonant.api.grid.INodeProvider;
import resonantinduction.core.interfaces.IMechanicalNode;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
import resonantinduction.mechanical.gear.PartGear;
import universalelectricity.api.vector.Vector3;
public class GearShaftNode extends MechanicalNode
{
public GearShaftNode(PartGearShaft parent)
{
super(parent);
}
public GearShaftNode(PartGearShaft parent)
{
super(parent);
}
@Override
public double getTorqueLoad()
{
// Decelerate the gear based on tier.
switch (shaft().tier)
{
default:
return 0.03;
case 1:
return 0.02;
case 2:
return 0.01;
}
}
@Override
public double getTorqueLoad()
{
// Decelerate the gear based on tier.
switch (shaft().tier)
{
default:
return 0.03;
case 1:
return 0.02;
case 2:
return 0.01;
}
}
@Override
public double getAngularVelocityLoad()
{
return 0;
}
@Override
public double getAngularVelocityLoad()
{
return 0;
}
@Override
public void recache()
{
getConnections().clear();
List<ForgeDirection> dirs = new ArrayList<ForgeDirection>();
dirs.add(shaft().placementSide);
dirs.add(shaft().placementSide.getOpposite());
/** Check for internal connections, the FRONT and BACK. */
Iterator<ForgeDirection> it = dirs.iterator();
while (it.hasNext())
{
ForgeDirection checkDir = it.next();
if (checkDir == shaft().placementSide || checkDir == shaft().placementSide.getOpposite())
{
if (shaft().tile() instanceof INodeProvider)
{
MechanicalNode instance = (MechanicalNode) ((INodeProvider) shaft().tile()).getNode(MechanicalNode.class, checkDir);
@Override
public void recache()
{
synchronized (this)
{
getConnections().clear();
List<ForgeDirection> dirs = new ArrayList<ForgeDirection>();
dirs.add(shaft().placementSide);
dirs.add(shaft().placementSide.getOpposite());
/** Check for internal connections, the FRONT and BACK. */
Iterator<ForgeDirection> it = dirs.iterator();
while (it.hasNext())
{
ForgeDirection checkDir = it.next();
if (checkDir == shaft().placementSide || checkDir == shaft().placementSide.getOpposite())
{
if (shaft().tile() instanceof INodeProvider)
{
MechanicalNode instance = (MechanicalNode) ((INodeProvider) shaft().tile()).getNode(MechanicalNode.class, checkDir);
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this))
{
getConnections().put(instance, checkDir);
it.remove();
}
}
}
}
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this))
{
getConnections().put(instance, checkDir);
it.remove();
}
}
}
}
/** Look for connections outside this block space, the relative FRONT and BACK */
if (!dirs.isEmpty())
for (ForgeDirection checkDir : dirs)
{
if (!getConnections().containsValue(checkDir) && (checkDir == shaft().placementSide || checkDir == shaft().placementSide.getOpposite()))
{
TileEntity checkTile = new universalelectricity.api.vector.Vector3(shaft().tile()).translate(checkDir).getTileEntity(world());
/** Look for connections outside this block space, the relative FRONT and BACK */
if (!dirs.isEmpty())
for (ForgeDirection checkDir : dirs)
{
if (!getConnections().containsValue(checkDir) && (checkDir == shaft().placementSide || checkDir == shaft().placementSide.getOpposite()))
{
TileEntity checkTile = new Vector3(shaft().tile()).translate(checkDir).getTileEntity(world());
if (checkTile instanceof INodeProvider)
{
MechanicalNode instance = (MechanicalNode) ((INodeProvider) checkTile).getNode(MechanicalNode.class, checkDir.getOpposite());
if (checkTile instanceof INodeProvider)
{
MechanicalNode instance = (MechanicalNode) ((INodeProvider) checkTile).getNode(MechanicalNode.class, checkDir.getOpposite());
// Only connect to shafts outside of this block space.
if (instance != null && instance != this && instance.getParent() instanceof PartGearShaft && instance.canConnect(checkDir.getOpposite(), this))
{
getConnections().put(instance, checkDir);
}
}
}
}
}
// Only connect to shafts outside of this block space.
if (instance != null && instance != this && instance.getParent() instanceof PartGearShaft && instance.canConnect(checkDir.getOpposite(), this))
{
getConnections().put(instance, checkDir);
}
}
}
}
}
}
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
if (source instanceof MechanicalNode)
{
if (((MechanicalNode) source).getParent() instanceof PartGear)
{
PartGear gear = (PartGear) ((MechanicalNode) source).getParent();
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
if (source instanceof MechanicalNode)
{
if (((MechanicalNode) source).getParent() instanceof PartGear)
{
PartGear gear = (PartGear) ((MechanicalNode) source).getParent();
if (!(Math.abs(gear.placementSide.offsetX) == Math.abs(shaft().placementSide.offsetX) && Math.abs(gear.placementSide.offsetY) == Math.abs(shaft().placementSide.offsetY) && Math.abs(gear.placementSide.offsetZ) == Math.abs(shaft().placementSide.offsetZ)))
{
return false;
}
}
}
if (!(Math.abs(gear.placementSide.offsetX) == Math.abs(shaft().placementSide.offsetX) && Math.abs(gear.placementSide.offsetY) == Math.abs(shaft().placementSide.offsetY) && Math.abs(gear.placementSide.offsetZ) == Math.abs(shaft().placementSide.offsetZ)))
{
return false;
}
}
}
return from == shaft().placementSide || from == shaft().placementSide.getOpposite();
}
return from == shaft().placementSide || from == shaft().placementSide.getOpposite();
}
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
if (shaft().placementSide.offsetY != 0 || shaft().placementSide.offsetZ != 0)
{
return dir == shaft().placementSide.getOpposite();
}
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
if (shaft().placementSide.offsetY != 0 || shaft().placementSide.offsetZ != 0)
{
return dir == shaft().placementSide.getOpposite();
}
return dir == shaft().placementSide;
}
return dir == shaft().placementSide;
}
public PartGearShaft shaft()
{
return (PartGearShaft) this.getParent();
}
public PartGearShaft shaft()
{
return (PartGearShaft) this.getParent();
}
}

View File

@ -18,62 +18,61 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderMechanicalPiston extends TileEntitySpecialRenderer
{
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "piston/mechanicalPiston.tcn");
public static ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "piston/mechanicalPiston_iron.png");
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "piston/mechanicalPiston.tcn");
public static ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "piston/mechanicalPiston_iron.png");
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
TileMechanicalPiston tile = (TileMechanicalPiston) tileEntity;
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
TileMechanicalPiston tile = (TileMechanicalPiston) tileEntity;
GL11.glRotated(-90, 0, 1, 0);
GL11.glRotated(180, 0, 0, 1);
GL11.glRotated(-90, 0, 1, 0);
GL11.glRotated(180, 0, 0, 1);
if (tile.worldObj != null)
{
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection());
}
if (tile.worldObj != null)
{
if (tile.getDirection() != ForgeDirection.UP && tile.getDirection() != ForgeDirection.DOWN)
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection().getOpposite());
else
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection());
}
RenderUtility.bind(TEXTURE);
RenderUtility.bind(TEXTURE);
// Angle in radians of the rotor.
double angle = tile.mechanicalNode.renderAngle;
final String[] staticParts = { "baseRing", "leg1", "leg2", "leg3", "leg4", "connector", "basePlate", "basePlateTop", "connectorBar", "centerPiston" };
final String[] shaftParts = { "topPlate", "outerPiston" };
// Angle in radians of the rotor.
double angle = tile.mechanicalNode.renderAngle;
final String[] staticParts = { "baseRing", "leg1", "leg2", "leg3", "leg4", "connector", "basePlate", "basePlateTop", "connectorBar", "centerPiston" };
final String[] shaftParts = { "topPlate", "outerPiston" };
/**
* Render Piston Rotor
*/
GL11.glPushMatrix();
GL11.glRotated(-Math.toDegrees(angle), 0, 0, 1);
MODEL.renderAllExcept(ArrayUtils.addAll(shaftParts, staticParts));
GL11.glPopMatrix();
/** Render Piston Rotor */
GL11.glPushMatrix();
GL11.glRotated(-Math.toDegrees(angle), 0, 0, 1);
MODEL.renderAllExcept(ArrayUtils.addAll(shaftParts, staticParts));
GL11.glPopMatrix();
/**
* Render Piston Shaft
*/
GL11.glPushMatrix();
/** Render Piston Shaft */
GL11.glPushMatrix();
if (tile.worldObj != null)
{
ForgeDirection dir = tile.getDirection();
if (tile.worldObj != null)
{
ForgeDirection dir = tile.getDirection();
if (tile.world().isAirBlock(tile.x() + dir.offsetX, tile.y() + dir.offsetY, tile.z() + dir.offsetZ))
{
GL11.glTranslated(0, 0, (0.4 * Math.sin(angle)) - 0.5);
}
else
{
GL11.glTranslated(0, 0, (0.06 * Math.sin(angle)) - 0.03);
}
}
if (tile.world().isAirBlock(tile.x() + dir.offsetX, tile.y() + dir.offsetY, tile.z() + dir.offsetZ))
{
GL11.glTranslated(0, 0, (0.4 * Math.sin(angle)) - 0.5);
}
else
{
GL11.glTranslated(0, 0, (0.06 * Math.sin(angle)) - 0.03);
}
}
MODEL.renderOnly(shaftParts);
GL11.glPopMatrix();
MODEL.renderOnly(shaftParts);
GL11.glPopMatrix();
MODEL.renderOnly(staticParts);
GL11.glPopMatrix();
}
MODEL.renderOnly(staticParts);
GL11.glPopMatrix();
}
}

View File

@ -1,7 +1,7 @@
package resonantinduction.mechanical.process.crusher;
import java.lang.reflect.Method;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
@ -19,243 +19,243 @@ import resonantinduction.core.ResonantInduction;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
import resonantinduction.mechanical.energy.grid.TileMechanical;
import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.ReflectionHelper;
import java.lang.reflect.Method;
public class TileMechanicalPiston extends TileMechanical implements IRotatable
{
@Config
private static int mechanicalPistonBreakCount = 5;
@Config(comment = "Outdated, not used anymore. use mechanicalPistonMultiplier as its based on block hardness now")
@Deprecated
private static int mechanicalPistonBreakCount = 5;
private int breakCount = mechanicalPistonBreakCount;
@Config
private static int mechanicalPistonMultiplier = 2;
private boolean markRevolve = false;
private boolean markRevolve = false;
public TileMechanicalPiston()
{
super(Material.piston);
public TileMechanicalPiston()
{
super(Material.piston);
mechanicalNode = new MechanicalNode(this)
{
@Override
protected void revolve()
{
markRevolve = true;
}
mechanicalNode = new MechanicalNode(this)
{
@Override
protected void revolve()
{
markRevolve = true;
}
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
return from != getDirection();
}
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
return from != getDirection();
}
}.setLoad(0.5f);
}.setLoad(0.5f);
isOpaqueCube = false;
normalRender = false;
customItemRender = true;
rotationMask = Byte.parseByte("111111", 2);
textureName = "material_steel_dark";
}
isOpaqueCube = false;
normalRender = false;
customItemRender = true;
rotationMask = Byte.parseByte("111111", 2);
textureName = "material_steel_dark";
}
@Override
public void updateEntity()
{
super.updateEntity();
@Override
public void updateEntity()
{
super.updateEntity();
if (markRevolve)
{
Vector3 movePosition = new Vector3(TileMechanicalPiston.this).translate(getDirection());
if (markRevolve)
{
Vector3 movePosition = new Vector3(TileMechanicalPiston.this).translate(getDirection());
if (!hitOreBlock(movePosition))
{
if (!worldObj.isRemote)
{
Vector3 moveNewPosition = movePosition.clone().translate(getDirection());
if (!hitOreBlock(movePosition))
{
if (!worldObj.isRemote)
{
Vector3 moveNewPosition = movePosition.clone().translate(getDirection());
if (canMove(movePosition, moveNewPosition))
move(movePosition, moveNewPosition);
}
}
if (canMove(movePosition, moveNewPosition))
{
move(movePosition, moveNewPosition);
}
}
}
markRevolve = false;
}
}
markRevolve = false;
}
}
public boolean hitOreBlock(Vector3 blockPos)
{
Block block = Block.blocksList[blockPos.getBlockID(world())];
public boolean hitOreBlock(Vector3 blockPos)
{
Block block = Block.blocksList[blockPos.getBlockID(world())];
if (block != null)
{
ItemStack blockStack = new ItemStack(block);
RecipeResource[] resources = MachineRecipes.INSTANCE.getOutput(ResonantInduction.RecipeType.CRUSHER.name(), blockStack);
if (block != null)
{
int breakCount = (int) (mechanicalPistonMultiplier * block.blockHardness);
final int startBreakCount = breakCount;
if (resources.length > 0)
{
if (!worldObj.isRemote)
{
int breakStatus = (int) (((float) (mechanicalPistonBreakCount - breakCount) / (float) mechanicalPistonBreakCount) * 10f);
world().destroyBlockInWorldPartially(0, blockPos.intX(), blockPos.intY(), blockPos.intZ(), breakStatus);
ItemStack blockStack = new ItemStack(block);
RecipeResource[] resources = MachineRecipes.INSTANCE.getOutput(ResonantInduction.RecipeType.CRUSHER.name(), blockStack);
if (breakCount <= 0)
{
if (!world().isRemote)
{
for (RecipeResource recipe : resources)
{
if (Math.random() <= recipe.getChance())
{
InventoryUtility.dropItemStack(world(), blockPos.clone().translate(0.5), recipe.getItemStack(), 10, 0);
}
}
if (resources.length > 0)
{
if (!worldObj.isRemote)
{
int breakStatus = (int) (((float) (startBreakCount - breakCount) / (float) startBreakCount) * 10f);
world().destroyBlockInWorldPartially(0, blockPos.intX(), blockPos.intY(), blockPos.intZ(), breakStatus);
ResonantInduction.LOGGER.info("[Mechanical Piston] Break Count: " + breakCount);
if (breakCount >= mechanicalPistonMultiplier)
{
for (RecipeResource recipe : resources)
{
if (Math.random() <= recipe.getChance())
{
InventoryUtility.dropItemStack(world(), blockPos.clone().translate(0.5), recipe.getItemStack(), 10, 0);
}
}
getWorldObj().destroyBlock(blockPos.intX(), blockPos.intY(), blockPos.intZ(), false);
}
getWorldObj().destroyBlock(blockPos.intX(), blockPos.intY(), blockPos.intZ(), false);
}
}
breakCount = mechanicalPistonBreakCount;
}
}
ResonantInduction.proxy.renderBlockParticle(worldObj, blockPos.clone().translate(0.5), new Vector3((Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3), block.blockID, 1);
breakCount--;
return true;
}
}
ResonantInduction.proxy.renderBlockParticle(worldObj, blockPos.clone().translate(0.5), new Vector3((Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3), block.blockID, 1);
breakCount--;
return true;
}
}
if (!worldObj.isRemote)
{
world().destroyBlockInWorldPartially(0, blockPos.intX(), blockPos.intY(), blockPos.intZ(), -1);
}
return false;
}
breakCount = mechanicalPistonBreakCount;
@Override
public void onRemove(int par5, int par6)
{
super.onRemove(par5, par6);
}
if (!worldObj.isRemote)
world().destroyBlockInWorldPartially(0, blockPos.intX(), blockPos.intY(), blockPos.intZ(), -1);
return false;
}
public boolean canMove(Vector3 from, Vector3 to)
{
TileEntity tileEntity = from.getTileEntity(worldObj);
@Override
public void onRemove(int par5, int par6)
{
super.onRemove(par5, par6);
}
if (this.equals(to.getTileEntity(getWorldObj())))
{
return false;
}
public boolean canMove(Vector3 from, Vector3 to)
{
TileEntity tileEntity = from.getTileEntity(worldObj);
/** Check Target */
int targetBlockID = to.getBlockID(worldObj);
if (this.equals(to.getTileEntity(getWorldObj())))
{
return false;
}
if (!(worldObj.isAirBlock(to.intX(), to.intY(), to.intZ()) || (targetBlockID > 0 && (Block.blocksList[targetBlockID].isBlockReplaceable(worldObj, to.intX(), to.intY(), to.intZ())))))
{
return false;
}
/** Check Target */
int targetBlockID = to.getBlockID(worldObj);
return true;
}
if (!(worldObj.isAirBlock(to.intX(), to.intY(), to.intZ()) || (targetBlockID > 0 && (Block.blocksList[targetBlockID].isBlockReplaceable(worldObj, to.intX(), to.intY(), to.intZ())))))
{
return false;
}
public void move(Vector3 from, Vector3 to)
{
int blockID = from.getBlockID(worldObj);
int blockMetadata = from.getBlockMetadata(worldObj);
return true;
}
TileEntity tileEntity = from.getTileEntity(worldObj);
public void move(Vector3 from, Vector3 to)
{
int blockID = from.getBlockID(worldObj);
int blockMetadata = from.getBlockMetadata(worldObj);
NBTTagCompound tileData = new NBTTagCompound();
TileEntity tileEntity = from.getTileEntity(worldObj);
if (tileEntity != null)
{
tileEntity.writeToNBT(tileData);
}
NBTTagCompound tileData = new NBTTagCompound();
MovementUtility.setBlockSneaky(worldObj, from, 0, 0, null);
if (tileEntity != null)
{
tileEntity.writeToNBT(tileData);
}
if (tileEntity != null && tileData != null)
{
/** Forge Multipart Support. Use FMP's custom TE creator. */
boolean isMultipart = tileData.getString("id").equals("savedMultipart");
MovementUtility.setBlockSneaky(worldObj, from, 0, 0, null);
TileEntity newTile = null;
if (tileEntity != null && tileData != null)
{
/**
* Forge Multipart Support. Use FMP's custom TE creator.
*/
boolean isMultipart = tileData.getString("id").equals("savedMultipart");
if (isMultipart)
{
try
{
Class multipart = Class.forName("codechicken.multipart.MultipartHelper");
Method m = multipart.getMethod("createTileFromNBT", World.class, NBTTagCompound.class);
newTile = (TileEntity) m.invoke(null, worldObj, tileData);
}
catch (Exception e)
{
e.printStackTrace();
}
}
else
{
newTile = TileEntity.createAndLoadEntity(tileData);
}
TileEntity newTile = null;
MovementUtility.setBlockSneaky(worldObj, to, blockID, blockMetadata, newTile);
if (isMultipart)
{
try
{
Class multipart = Class.forName("codechicken.multipart.MultipartHelper");
Method m = multipart.getMethod("createTileFromNBT", World.class, NBTTagCompound.class);
newTile = (TileEntity) m.invoke(null, worldObj, tileData);
}
catch (Exception e)
{
e.printStackTrace();
}
}
else
{
newTile = TileEntity.createAndLoadEntity(tileData);
}
if (newTile != null && isMultipart)
{
try
{
// Send the description packet of the TE after moving it.
Class multipart = Class.forName("codechicken.multipart.MultipartHelper");
multipart.getMethod("sendDescPacket", World.class, TileEntity.class).invoke(null, worldObj, newTile);
MovementUtility.setBlockSneaky(worldObj, to, blockID, blockMetadata, newTile);
// Call onMoved event.
Class tileMultipart = Class.forName("codechicken.multipart.TileMultipart");
tileMultipart.getMethod("onMoved").invoke(newTile);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
else
{
MovementUtility.setBlockSneaky(worldObj, to, blockID, blockMetadata, null);
}
if (newTile != null && isMultipart)
{
try
{
// Send the description packet of the TE after moving it.
Class multipart = Class.forName("codechicken.multipart.MultipartHelper");
multipart.getMethod("sendDescPacket", World.class, TileEntity.class).invoke(null, worldObj, newTile);
notifyChanges(from);
notifyChanges(to);
}
// Call onMoved event.
Class tileMultipart = Class.forName("codechicken.multipart.TileMultipart");
tileMultipart.getMethod("onMoved").invoke(newTile);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
else
{
MovementUtility.setBlockSneaky(worldObj, to, blockID, blockMetadata, null);
}
public void notifyChanges(Vector3 pos)
{
worldObj.notifyBlocksOfNeighborChange(pos.intX(), pos.intY(), pos.intZ(), pos.getBlockID(worldObj));
notifyChanges(from);
notifyChanges(to);
}
TileEntity newTile = pos.getTileEntity(worldObj);
public void notifyChanges(Vector3 pos)
{
worldObj.notifyBlocksOfNeighborChange(pos.intX(), pos.intY(), pos.intZ(), pos.getBlockID(worldObj));
if (newTile != null)
{
if (Loader.isModLoaded("BuildCraft|Factory"))
{
/** Special quarry compatibility code. */
try
{
Class clazz = Class.forName("buildcraft.factory.TileQuarry");
TileEntity newTile = pos.getTileEntity(worldObj);
if (newTile != null)
{
if (Loader.isModLoaded("BuildCraft|Factory"))
{
/**
* Special quarry compatibility code.
*/
try
{
Class clazz = Class.forName("buildcraft.factory.TileQuarry");
if (newTile.equals(clazz))
{
ReflectionHelper.setPrivateValue(clazz, newTile, true, "isAlive");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
if (newTile.equals(clazz))
{
ReflectionHelper.setPrivateValue(clazz, newTile, true, "isAlive");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
}

View File

@ -0,0 +1,37 @@
package resonantinduction.mechanical.process.grinder;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.interfaces.IMechanicalNode;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
/** Node just for the grinder
*
* @author Darkguardsman */
public class GrinderNode extends MechanicalNode
{
public GrinderNode(TileGrindingWheel parent)
{
super(parent);
}
public TileGrindingWheel grider()
{
return (TileGrindingWheel) getParent();
}
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
if(grider().getDirection() == ForgeDirection.UP || grider().getDirection() == ForgeDirection.DOWN)
{
return grider().getDirection() == from || grider().getDirection().getOpposite() == from;
}
return grider().getDirection() != from && grider().getDirection().getOpposite() != from;
}
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
return !(dir.offsetX > 0 || dir.offsetZ < 0 || dir.offsetY < 0);
}
}

View File

@ -34,7 +34,7 @@ public class RenderGrindingWheel extends TileEntitySpecialRenderer
glTranslatef((float) x + 0.5F, (float) y + 0.5f, (float) z + 0.5F);
glScalef(0.51f, 0.5f, 0.5f);
ForgeDirection dir = tile.getDirection();
dir = ForgeDirection.getOrientation(!(dir.ordinal() % 2 == 0) ? dir.ordinal() - 1 : dir.ordinal());
//dir = ForgeDirection.getOrientation(!(dir.ordinal() % 2 == 0) ? dir.ordinal() - 1 : dir.ordinal());
RenderUtility.rotateBlockBasedOnDirection(dir);
glRotatef((float) Math.toDegrees(tile.mechanicalNode.renderAngle), 0, 0, 1);
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");

View File

@ -10,6 +10,7 @@ import net.minecraftforge.common.ForgeDirection;
import resonant.api.IRotatable;
import resonant.api.recipe.MachineRecipes;
import resonant.api.recipe.RecipeResource;
import resonant.lib.prefab.CustomDamageSource;
import resonant.lib.prefab.vector.Cuboid;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
@ -22,43 +23,24 @@ import universalelectricity.api.vector.Vector3;
/**
* @author Calclavia
*
*/
public class TileGrindingWheel extends TileMechanical implements IRotatable
{
public static final int PROCESS_TIME = 20 * 20;
/** A map of ItemStacks and their remaining grind-time left. */
public static final Timer<EntityItem> timer = new Timer<EntityItem>();
/**
* A map of ItemStacks and their remaining grind-time left.
*/
public static final Timer<EntityItem> timer = new Timer();
public EntityItem grindingItem = null;
private final long requiredTorque = 1000;
private final long requiredTorque = 250;
private double counter = 0;
public TileGrindingWheel()
{
super(Material.rock);
mechanicalNode = new MechanicalNode(this)
{
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
if (getDirection().ordinal() < 2)
{
return from.offsetY != 0;
}
return getDirection().getRotation(ForgeDirection.UP) == from || getDirection().getRotation(ForgeDirection.DOWN) == from;
}
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
return !(dir.offsetX > 0 || dir.offsetZ < 0 || dir.offsetY < 0);
}
}.setLoad(2);
mechanicalNode = new GrinderNode(this).setLoad(2);
bounds = new Cuboid(0.05f, 0.05f, 0.05f, 0.95f, 0.95f, 0.95f);
isOpaqueCube = false;
normalRender = false;
@ -67,6 +49,14 @@ public class TileGrindingWheel extends TileMechanical implements IRotatable
textureName = "material_steel_dark";
}
@Override
public void updateEntity()
{
super.updateEntity();
counter = Math.max(counter + Math.abs(mechanicalNode.torque), 0);
doWork();
}
@Override
public void collide(Entity entity)
{
@ -98,7 +88,7 @@ public class TileGrindingWheel extends TileMechanical implements IRotatable
}
else
{
entity.attackEntityFrom(DamageSource.cactus, 2);
entity.attackEntityFrom(new CustomDamageSource("grinder", this), 2);
}
}
@ -109,21 +99,28 @@ public class TileGrindingWheel extends TileMechanical implements IRotatable
ForgeDirection dir = getDirection();
dir = ForgeDirection.getOrientation(!(dir.ordinal() % 2 == 0) ? dir.ordinal() - 1 : dir.ordinal()).getOpposite();
double speed = mechanicalNode.getAngularSpeed() / 20;
entity.addVelocity(dir.offsetX * speed, Math.random() * speed, dir.offsetZ * speed);
double speedX = dir.offsetX * speed;
double speedZ = dir.offsetZ * speed;
double speedY = Math.random() * speed;
if (Math.abs(speedX) > 1)
{
speedX = speedX > 0 ? 1 : -1;
}
if (Math.abs(speedZ) > 1)
{
speedZ = speedZ > 0 ? 1 : -1;
}
if (Math.abs(speedZ) > 1)
{
speedY = speedY > 0 ? 1 : -1;
}
entity.addVelocity(speedX, speedY, speedZ);
}
}
@Override
public void updateEntity()
{
super.updateEntity();
counter = Math.max(counter + mechanicalNode.torque, 0);
doWork();
}
/**
* Can this machine work this tick?
*
*
* @return
*/
public boolean canWork()

View File

@ -0,0 +1,22 @@
package resonantinduction.mechanical.process.mixer;
import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INodeProvider;
import resonantinduction.core.interfaces.IMechanicalNode;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
public class MixerNode extends MechanicalNode
{
public MixerNode(INodeProvider parent)
{
super(parent);
}
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
return dir == ForgeDirection.DOWN;
}
}

View File

@ -1,4 +1,4 @@
package resonantinduction.mechanical.process.purifier;
package resonantinduction.mechanical.process.mixer;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;

View File

@ -1,4 +1,4 @@
package resonantinduction.mechanical.process.purifier;
package resonantinduction.mechanical.process.mixer;
import java.util.LinkedHashSet;
import java.util.List;
@ -41,17 +41,7 @@ public class TileMixer extends TileMechanical implements IInventory
public TileMixer()
{
super(Material.iron);
mechanicalNode = new MechanicalNode(this)
{
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
return dir == ForgeDirection.DOWN;
}
}.setConnection(Byte.parseByte("000011", 2));
mechanicalNode = new MixerNode(this).setConnection(Byte.parseByte("000011", 2));
isOpaqueCube = false;
normalRender = false;
customItemRender = true;

View File

@ -49,8 +49,8 @@ item.resonantinduction\:handCrank.name=Hand Crank
item.resonantinduction\:devStaff.name=Staff of Devs
item.resonantinduction\:flour.name=Flour
item.dough.name=Dough
item.resonantinduction\:laserDrill.name=Laser Drill
item.resonantinduction\:biomass.name=Biomass
## Machines
tile.resonantinduction\:castingMold.name=Casting Mold

Some files were not shown because too many files have changed in this diff Show More