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

View file

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

View file

@ -18,13 +18,13 @@ import net.minecraftforge.fluids.FluidTank;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import resonant.api.IRemovable.ISneakPickup; import resonant.api.IRemovable.ISneakPickup;
import resonant.api.items.ISimpleItemRenderer;
import resonant.lib.content.module.TileBlock.IComparatorInputOverride; import resonant.lib.content.module.TileBlock.IComparatorInputOverride;
import resonant.lib.content.module.TileRender; import resonant.lib.content.module.TileRender;
import resonant.lib.render.FluidRenderUtility; import resonant.lib.render.FluidRenderUtility;
import resonant.lib.render.RenderUtility; import resonant.lib.render.RenderUtility;
import resonant.lib.utility.FluidUtility; import resonant.lib.utility.FluidUtility;
import resonant.lib.utility.WorldUtility; import resonant.lib.utility.WorldUtility;
import resonant.lib.utility.inventory.InventoryUtility;
import resonant.lib.utility.render.RenderBlockUtility; import resonant.lib.utility.render.RenderBlockUtility;
import resonantinduction.archaic.Archaic; import resonantinduction.archaic.Archaic;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
@ -36,217 +36,262 @@ import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
/** Tile/Block class for basic Dynamic tanks /**
* * Tile/Block class for basic Dynamic tanks
* @author Darkguardsman */ *
* @author Darkguardsman
*/
public class TileTank extends TileFluidDistribution implements IComparatorInputOverride, ISneakPickup public class TileTank extends TileFluidDistribution implements IComparatorInputOverride, ISneakPickup
{ {
public static final int VOLUME = 16; public static final int VOLUME = 16;
public TileTank() public TileTank()
{ {
super(UniversalElectricity.machine, VOLUME * FluidContainerRegistry.BUCKET_VOLUME); super(UniversalElectricity.machine, VOLUME * FluidContainerRegistry.BUCKET_VOLUME);
isOpaqueCube = false; isOpaqueCube = false;
normalRender = false; normalRender = false;
itemBlock = ItemBlockTank.class; itemBlock = ItemBlockTank.class;
} }
@Override @Override
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side) 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; return access != null && block != null && access.getBlockId(x, y, z) != block.blockID;
} }
@Override @Override
protected boolean use(EntityPlayer player, int side, Vector3 vector3) protected boolean use(EntityPlayer player, int side, Vector3 vector3)
{ {
if (!world().isRemote) if (!world().isRemote)
{ {
return FluidUtility.playerActivatedFluidItem(world(), x(), y(), z(), player, side); return FluidUtility.playerActivatedFluidItem(world(), x(), y(), z(), player, side);
} }
return true; return true;
} }
@Override @Override
public int getComparatorInputOverride(int side) public int getComparatorInputOverride(int side)
{ {
if (getNetwork().getTank().getFluid() != null) if (getNetwork().getTank().getFluid() != null)
{ {
return (int) (15 * ((double) getNetwork().getTank().getFluidAmount() / (double) getNetwork().getTank().getCapacity())); return (int) (15 * ((double) getNetwork().getTank().getFluidAmount() / (double) getNetwork().getTank().getCapacity()));
} }
return 0; return 0;
} }
@Override @Override
public int getLightValue(IBlockAccess access) public int getLightValue(IBlockAccess access)
{ {
if (getInternalTank().getFluid() != null) if (getInternalTank().getFluid() != null)
{ {
return getInternalTank().getFluid().getFluid().getLuminosity(); return getInternalTank().getFluid().getFluid().getLuminosity();
} }
return super.getLightValue(access); return super.getLightValue(access);
} }
@Override @Override
public FluidDistributionetwork getNetwork() public FluidDistributionetwork getNetwork()
{ {
if (this.network == null) if (this.network == null)
{ {
this.network = new TankNetwork(); this.network = new TankNetwork();
this.network.addConnector(this); this.network.addConnector(this);
} }
return this.network; return this.network;
} }
@Override @Override
public void setNetwork(FluidDistributionetwork network) public void setNetwork(FluidDistributionetwork network)
{ {
if (network instanceof TankNetwork) if (network instanceof TankNetwork)
{ {
this.network = network; this.network = network;
} }
} }
@Override @Override
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side) public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
{ {
if (!this.worldObj.isRemote) if (!this.worldObj.isRemote)
{ {
if (tileEntity instanceof TileTank) if (tileEntity instanceof TileTank)
{ {
getNetwork().merge(((IFluidDistribution) tileEntity).getNetwork()); getNetwork().merge(((IFluidDistribution) tileEntity).getNetwork());
renderSides = WorldUtility.setEnableSide(renderSides, side, true); renderSides = WorldUtility.setEnableSide(renderSides, side, true);
connectedBlocks[side.ordinal()] = tileEntity; connectedBlocks[side.ordinal()] = tileEntity;
} }
} }
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
protected TileRender newRenderer() protected TileRender newRenderer()
{ {
return new TileRender() return new TileRender()
{ {
@Override @Override
public boolean renderStatic(RenderBlocks renderer, Vector3 position) public boolean renderStatic(RenderBlocks renderer, Vector3 position)
{ {
RenderBlockUtility.tessellateBlockWithConnectedTextures(renderSides, world(), x(), y(), z(), Archaic.blockTank, null, RenderUtility.getIcon(Reference.PREFIX + "tankEdge")); RenderBlockUtility.tessellateBlockWithConnectedTextures(renderSides, world(), x(), y(), z(), Archaic.blockTank, null, RenderUtility.getIcon(Reference.PREFIX + "tankEdge"));
return true; return true;
} }
public void renderTank(TileEntity tileEntity, double x, double y, double z, FluidStack fluid) public void renderTank(TileEntity tileEntity, double x, double y, double z, FluidStack fluid)
{ {
if (tileEntity.worldObj != null && tileEntity instanceof TileTank) if (tileEntity.worldObj != null && tileEntity instanceof TileTank)
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
if (fluid != null) if (fluid != null)
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
if (!fluid.getFluid().isGaseous()) if (!fluid.getFluid().isGaseous())
{ {
GL11.glScaled(0.99, 0.99, 0.99); GL11.glScaled(0.99, 0.99, 0.99);
FluidTank tank = ((TileTank) tileEntity).getInternalTank(); FluidTank tank = ((TileTank) tileEntity).getInternalTank();
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity(); 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 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 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 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); double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.WEST);
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest); FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
} }
else else
{ {
GL11.glTranslated(-0.5, -0.5, -0.5); GL11.glTranslated(-0.5, -0.5, -0.5);
GL11.glScaled(0.99, 0.99, 0.99); GL11.glScaled(0.99, 0.99, 0.99);
int capacity = tileEntity instanceof TileTank ? ((TileTank) tileEntity).getInternalTank().getCapacity() : fluid.amount; int capacity = tileEntity instanceof TileTank ? ((TileTank) tileEntity).getInternalTank().getCapacity() : fluid.amount;
double filledPercentage = (double) fluid.amount / (double) capacity; double filledPercentage = (double) fluid.amount / (double) capacity;
double renderPercentage = fluid.getFluid().isGaseous() ? 1 : filledPercentage; 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.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Color color = new Color(fluid.getFluid().getColor()); Color color = new Color(fluid.getFluid().getColor());
RenderUtility.enableBlending(); RenderUtility.enableBlending();
GL11.glColor4d(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, fluid.getFluid().isGaseous() ? filledPercentage : 1); GL11.glColor4d(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, fluid.getFluid().isGaseous() ? filledPercentage : 1);
RenderUtility.bind(FluidRenderUtility.getFluidSheet(fluid)); RenderUtility.bind(FluidRenderUtility.getFluidSheet(fluid));
GL11.glCallList(displayList[(int) (renderPercentage * (FluidRenderUtility.DISPLAY_STAGES - 1))]); GL11.glCallList(displayList[(int) (renderPercentage * (FluidRenderUtility.DISPLAY_STAGES - 1))]);
RenderUtility.disableBlending(); RenderUtility.disableBlending();
GL11.glPopAttrib(); GL11.glPopAttrib();
} }
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
} }
@Override @Override
public boolean renderDynamic(Vector3 position, boolean isItem, float frame) public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
{ {
renderTank(TileTank.this, position.x, position.y, position.z, getInternalTank().getFluid()); renderTank(TileTank.this, position.x, position.y, position.z, getInternalTank().getFluid());
return false; return false;
} }
};
}
@Override public static class ItemRenderer implements ISimpleItemRenderer
public boolean renderItem(ItemStack itemStack) {
{ public static ItemRenderer instance = new ItemRenderer();
GL11.glPushMatrix();
GL11.glTranslated(0.5, 0.5, 0.5);
RenderBlockUtility.tessellateBlockWithConnectedTextures(itemStack.getItemDamage(), Archaic.blockTank, null, RenderUtility.getIcon(Reference.PREFIX + "tankEdge"));
GL11.glPopMatrix();
GL11.glPushMatrix(); public void renderTank(double x, double y, double z, FluidStack fluid, int capacity)
GL11.glTranslated(0, -0.1, 0); {
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")) if (fluid != null)
{ {
fluid = FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("fluid")); GL11.glPushMatrix();
}
renderTank(TileTank.this, 0, 0, 0, fluid); if (!fluid.getFluid().isGaseous())
GL11.glPopMatrix(); {
return true; double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
} FluidRenderUtility.renderFluidTesselation(tank, percentageFilled, percentageFilled, percentageFilled, percentageFilled);
}; }
} else
{
double filledPercentage = (double) fluid.amount / (double) capacity;
@Override GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
public List<ItemStack> getRemovedItems(EntityPlayer entity) GL11.glEnable(GL11.GL_CULL_FACE);
{ GL11.glDisable(GL11.GL_LIGHTING);
List<ItemStack> drops = new ArrayList<ItemStack>(); 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); Color color = new Color(fluid.getFluid().getColor());
if (itemStack != null) RenderUtility.enableBlending();
{ GL11.glColor4d(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, fluid.getFluid().isGaseous() ? filledPercentage : 1);
if (getInternalTank() != null && getInternalTank().getFluid() != null)
{
FluidStack stack = getInternalTank().getFluid();
if (stack != null) RenderUtility.bind(FluidRenderUtility.getFluidSheet(fluid));
{ FluidRenderUtility.renderFluidTesselation(tank, 1, 1, 1, 1);
if (itemStack.getTagCompound() == null) RenderUtility.disableBlending();
{ GL11.glPopAttrib();
itemStack.setTagCompound(new NBTTagCompound()); }
}
drain(ForgeDirection.UNKNOWN, stack.amount, false); GL11.glPopMatrix();
itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound())); }
}
} GL11.glPopMatrix();
drops.add(itemStack); }
}
return drops; @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.Event.Result;
import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.FillBucketEvent; import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.event.world.WorldEvent.Save;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
@ -53,40 +52,38 @@ import resonant.lib.prefab.ore.OreGenerator;
import resonant.lib.recipe.UniversalRecipe; import resonant.lib.recipe.UniversalRecipe;
import resonant.lib.render.RenderUtility; import resonant.lib.render.RenderUtility;
import resonant.lib.thermal.EventThermal.EventThermalUpdate; import resonant.lib.thermal.EventThermal.EventThermalUpdate;
import resonant.lib.utility.nbt.NBTUtility; import resonantinduction.atomic.blocks.BlockToxicWaste;
import resonantinduction.atomic.base.ItemCell; import resonantinduction.atomic.blocks.BlockUraniumOre;
import resonantinduction.atomic.fission.BlockUraniumOre; import resonantinduction.atomic.blocks.TileElectromagnet;
import resonantinduction.atomic.fission.ItemBreederFuel; import resonantinduction.atomic.blocks.TileSiren;
import resonantinduction.atomic.fission.ItemFissileFuel; import resonantinduction.atomic.items.ItemAntimatter;
import resonantinduction.atomic.fission.ItemRadioactive; import resonantinduction.atomic.items.ItemBreederFuel;
import resonantinduction.atomic.fission.ItemUranium; import resonantinduction.atomic.items.ItemCell;
import resonantinduction.atomic.fission.reactor.BlockToxicWaste; import resonantinduction.atomic.items.ItemDarkMatter;
import resonantinduction.atomic.fission.reactor.TileControlRod; import resonantinduction.atomic.items.ItemFissileFuel;
import resonantinduction.atomic.fission.reactor.TileReactorCell; import resonantinduction.atomic.items.ItemHazmat;
import resonantinduction.atomic.fusion.BlockPlasmaHeater; import resonantinduction.atomic.items.ItemRadioactive;
import resonantinduction.atomic.fusion.TileElectromagnet; import resonantinduction.atomic.items.ItemUranium;
import resonantinduction.atomic.fusion.TilePlasma; import resonantinduction.atomic.machine.accelerator.EntityParticle;
import resonantinduction.atomic.fusion.TilePlasmaHeater; import resonantinduction.atomic.machine.accelerator.TileAccelerator;
import resonantinduction.atomic.particle.accelerator.BlockAccelerator; import resonantinduction.atomic.machine.boiler.BlockNuclearBoiler;
import resonantinduction.atomic.particle.accelerator.EntityParticle; import resonantinduction.atomic.machine.boiler.TileNuclearBoiler;
import resonantinduction.atomic.particle.accelerator.ItemDarkMatter; import resonantinduction.atomic.machine.centrifuge.BlockCentrifuge;
import resonantinduction.atomic.particle.accelerator.TileAccelerator; import resonantinduction.atomic.machine.centrifuge.TileCentrifuge;
import resonantinduction.atomic.particle.fulmination.FulminationHandler; import resonantinduction.atomic.machine.extractor.BlockChemicalExtractor;
import resonantinduction.atomic.particle.fulmination.ItemAntimatter; import resonantinduction.atomic.machine.extractor.TileChemicalExtractor;
import resonantinduction.atomic.particle.fulmination.TileFulmination; import resonantinduction.atomic.machine.extractor.turbine.BlockElectricTurbine;
import resonantinduction.atomic.particle.quantum.TileQuantumAssembler; import resonantinduction.atomic.machine.extractor.turbine.TileElectricTurbine;
import resonantinduction.atomic.process.BlockChemicalExtractor; import resonantinduction.atomic.machine.extractor.turbine.TileFunnel;
import resonantinduction.atomic.process.ItemHazmat; import resonantinduction.atomic.machine.fulmination.FulminationHandler;
import resonantinduction.atomic.process.TileChemicalExtractor; import resonantinduction.atomic.machine.fulmination.TileFulmination;
import resonantinduction.atomic.process.fission.BlockCentrifuge; import resonantinduction.atomic.machine.plasma.BlockPlasmaHeater;
import resonantinduction.atomic.process.fission.BlockNuclearBoiler; import resonantinduction.atomic.machine.plasma.TilePlasma;
import resonantinduction.atomic.process.fission.TileCentrifuge; import resonantinduction.atomic.machine.plasma.TilePlasmaHeater;
import resonantinduction.atomic.process.fission.TileNuclearBoiler; import resonantinduction.atomic.machine.quantum.TileQuantumAssembler;
import resonantinduction.atomic.process.sensor.TileSiren; import resonantinduction.atomic.machine.reactor.TileControlRod;
import resonantinduction.atomic.process.sensor.TileThermometer; import resonantinduction.atomic.machine.reactor.TileReactorCell;
import resonantinduction.atomic.process.turbine.BlockElectricTurbine; import resonantinduction.atomic.machine.thermometer.TileThermometer;
import resonantinduction.atomic.process.turbine.TileElectricTurbine;
import resonantinduction.atomic.process.turbine.TileFunnel;
import resonantinduction.atomic.schematic.SchematicAccelerator; import resonantinduction.atomic.schematic.SchematicAccelerator;
import resonantinduction.atomic.schematic.SchematicBreedingReactor; import resonantinduction.atomic.schematic.SchematicBreedingReactor;
import resonantinduction.atomic.schematic.SchematicFissionReactor; import resonantinduction.atomic.schematic.SchematicFissionReactor;
@ -305,7 +302,7 @@ public class Atomic
blockElectromagnet = contentRegistry.newBlock(TileElectromagnet.class); blockElectromagnet = contentRegistry.newBlock(TileElectromagnet.class);
blockSiren = contentRegistry.newBlock(TileSiren.class); blockSiren = contentRegistry.newBlock(TileSiren.class);
blockSteamFunnel = contentRegistry.newBlock(TileFunnel.class); blockSteamFunnel = contentRegistry.newBlock(TileFunnel.class);
blockAccelerator = contentRegistry.createTile(BlockAccelerator.class, TileAccelerator.class); blockAccelerator = contentRegistry.newBlock(TileAccelerator.class);
blockFulmination = contentRegistry.newBlock(TileFulmination.class); blockFulmination = contentRegistry.newBlock(TileFulmination.class);
blockQuantumAssembler = contentRegistry.newBlock(TileQuantumAssembler.class); blockQuantumAssembler = contentRegistry.newBlock(TileQuantumAssembler.class);
blockToxicWaste = contentRegistry.createBlock(BlockToxicWaste.class).setCreativeTab(null); 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.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import resonant.lib.render.block.BlockRenderingHandler; import resonant.lib.render.block.BlockRenderingHandler;
import resonantinduction.atomic.fission.reactor.GuiReactorCell; import resonantinduction.atomic.machine.accelerator.EntityParticle;
import resonantinduction.atomic.fission.reactor.RenderReactorCell; import resonantinduction.atomic.machine.accelerator.GuiAccelerator;
import resonantinduction.atomic.fission.reactor.TileReactorCell; import resonantinduction.atomic.machine.accelerator.RenderParticle;
import resonantinduction.atomic.fusion.RenderPlasmaHeater; import resonantinduction.atomic.machine.accelerator.TileAccelerator;
import resonantinduction.atomic.fusion.TilePlasmaHeater; import resonantinduction.atomic.machine.boiler.GuiChemicalExtractor;
import resonantinduction.atomic.particle.accelerator.EntityParticle; import resonantinduction.atomic.machine.boiler.GuiNuclearBoiler;
import resonantinduction.atomic.particle.accelerator.GuiAccelerator; import resonantinduction.atomic.machine.boiler.RenderNuclearBoiler;
import resonantinduction.atomic.particle.accelerator.RenderParticle; import resonantinduction.atomic.machine.boiler.TileNuclearBoiler;
import resonantinduction.atomic.particle.accelerator.TileAccelerator; import resonantinduction.atomic.machine.centrifuge.GuiCentrifuge;
import resonantinduction.atomic.particle.quantum.GuiQuantumAssembler; import resonantinduction.atomic.machine.centrifuge.RenderCentrifuge;
import resonantinduction.atomic.particle.quantum.TileQuantumAssembler; import resonantinduction.atomic.machine.centrifuge.TileCentrifuge;
import resonantinduction.atomic.process.RenderChemicalExtractor; import resonantinduction.atomic.machine.extractor.RenderChemicalExtractor;
import resonantinduction.atomic.process.TileChemicalExtractor; import resonantinduction.atomic.machine.extractor.TileChemicalExtractor;
import resonantinduction.atomic.process.fission.GuiCentrifuge; import resonantinduction.atomic.machine.extractor.turbine.RenderElectricTurbine;
import resonantinduction.atomic.process.fission.GuiChemicalExtractor; import resonantinduction.atomic.machine.extractor.turbine.TileElectricTurbine;
import resonantinduction.atomic.process.fission.GuiNuclearBoiler; import resonantinduction.atomic.machine.plasma.RenderPlasmaHeater;
import resonantinduction.atomic.process.fission.RenderCentrifuge; import resonantinduction.atomic.machine.plasma.TilePlasmaHeater;
import resonantinduction.atomic.process.fission.RenderNuclearBoiler; import resonantinduction.atomic.machine.quantum.GuiQuantumAssembler;
import resonantinduction.atomic.process.fission.TileCentrifuge; import resonantinduction.atomic.machine.quantum.TileQuantumAssembler;
import resonantinduction.atomic.process.fission.TileNuclearBoiler; import resonantinduction.atomic.machine.reactor.GuiReactorCell;
import resonantinduction.atomic.process.sensor.RenderThermometer; import resonantinduction.atomic.machine.reactor.RenderReactorCell;
import resonantinduction.atomic.process.sensor.TileThermometer; import resonantinduction.atomic.machine.reactor.TileReactorCell;
import resonantinduction.atomic.process.turbine.RenderElectricTurbine; import resonantinduction.atomic.machine.thermometer.RenderThermometer;
import resonantinduction.atomic.process.turbine.TileElectricTurbine; import resonantinduction.atomic.machine.thermometer.TileThermometer;
import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry; 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.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonant.lib.prefab.ProxyBase; import resonant.lib.prefab.ProxyBase;
import resonantinduction.atomic.fission.reactor.ContainerReactorCell; import resonantinduction.atomic.machine.accelerator.ContainerAccelerator;
import resonantinduction.atomic.fission.reactor.TileReactorCell; import resonantinduction.atomic.machine.accelerator.TileAccelerator;
import resonantinduction.atomic.fusion.ContainerNuclearBoiler; import resonantinduction.atomic.machine.boiler.TileNuclearBoiler;
import resonantinduction.atomic.particle.accelerator.ContainerAccelerator; import resonantinduction.atomic.machine.centrifuge.ContainerCentrifuge;
import resonantinduction.atomic.particle.accelerator.TileAccelerator; import resonantinduction.atomic.machine.centrifuge.TileCentrifuge;
import resonantinduction.atomic.particle.quantum.ContainerQuantumAssembler; import resonantinduction.atomic.machine.extractor.ContainerChemicalExtractor;
import resonantinduction.atomic.particle.quantum.TileQuantumAssembler; import resonantinduction.atomic.machine.extractor.TileChemicalExtractor;
import resonantinduction.atomic.process.ContainerChemicalExtractor; import resonantinduction.atomic.machine.plasma.ContainerNuclearBoiler;
import resonantinduction.atomic.process.TileChemicalExtractor; import resonantinduction.atomic.machine.quantum.ContainerQuantumAssembler;
import resonantinduction.atomic.process.fission.ContainerCentrifuge; import resonantinduction.atomic.machine.quantum.TileQuantumAssembler;
import resonantinduction.atomic.process.fission.TileCentrifuge; import resonantinduction.atomic.machine.reactor.ContainerReactorCell;
import resonantinduction.atomic.process.fission.TileNuclearBoiler; import resonantinduction.atomic.machine.reactor.TileReactorCell;
public class CommonProxy extends ProxyBase 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; import java.util.Random;

View file

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

View file

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

View file

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.fulmination; package resonantinduction.atomic.items;
import java.util.List; import java.util.List;
@ -19,7 +19,6 @@ import resonant.api.explosion.IExplosion;
import resonant.lib.flag.FlagRegistry; import resonant.lib.flag.FlagRegistry;
import resonant.lib.prefab.poison.PoisonRadiation; import resonant.lib.prefab.poison.PoisonRadiation;
import resonantinduction.atomic.Atomic; import resonantinduction.atomic.Atomic;
import resonantinduction.atomic.base.ItemCell;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings; import resonantinduction.core.Settings;
@ -43,6 +42,8 @@ public class ItemAntimatter extends ItemCell
@Override @Override
public void registerIcons(IconRegister iconRegister) 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.itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", "") + "_milligram");
this.iconGram = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", "") + "_gram"); this.iconGram = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", "") + "_gram");
} }
@ -74,7 +75,7 @@ public class ItemAntimatter extends ItemCell
} }
@ForgeSubscribe @ForgeSubscribe
public void baoZhaEvent(ItemExpireEvent evt) public void antimatterExpireEvent(ItemExpireEvent evt)
{ {
if (evt.entityItem != null) 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))) 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)); 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); 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); 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; 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); super(par1World, par2Entity, x, y, z, size + 2 * tier);
this.tier = 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.item.ItemStack;
import net.minecraft.tileentity.TileEntity; 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; import java.util.List;
@ -11,6 +11,7 @@ import net.minecraftforge.fluids.FluidStack;
import resonant.api.IReactor; import resonant.api.IReactor;
import resonant.api.IReactorComponent; import resonant.api.IReactorComponent;
import resonantinduction.atomic.Atomic; import resonantinduction.atomic.Atomic;
import resonantinduction.atomic.machine.reactor.TileReactorCell;
import resonantinduction.core.Settings; import resonantinduction.core.Settings;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -22,7 +23,7 @@ public class ItemFissileFuel extends ItemRadioactive implements IReactorComponen
public static final int DECAY = 2500; public static final int DECAY = 2500;
/** Temperature at which the fuel rod will begin to re-enrich itself. */ /** 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. */ /** The energy in one KG of uranium is: 72PJ, 100TJ in one cell of uranium. */
public static final long ENERGY = 100000000000L; public static final long ENERGY = 100000000000L;
@ -51,7 +52,7 @@ public class ItemFissileFuel extends ItemRadioactive implements IReactorComponen
TileEntity tile = checkPos.getTileEntity(worldObj); TileEntity tile = checkPos.getTileEntity(worldObj);
// Check that the other reactors not only exist but also are running. // 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++; reactors++;
} }
@ -61,12 +62,15 @@ public class ItemFissileFuel extends ItemRadioactive implements IReactorComponen
if (reactors >= 2) if (reactors >= 2)
{ {
// Begin the process of re-enriching the uranium rod but not consistently. // 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. // Cells can regain a random amount of health per tick.
int healAmt = worldObj.rand.nextInt(5); 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)); 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 else

View file

@ -1,4 +1,4 @@
package resonantinduction.atomic.process; package resonantinduction.atomic.items;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; 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.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;

View file

@ -1,4 +1,4 @@
package resonantinduction.atomic.fission; package resonantinduction.atomic.items;
import java.util.List; 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.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; 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 java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -51,9 +52,10 @@ public class EntityParticle extends Entity implements IEntityAdditionalSpawnData
this.movementDirection = dir; 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; return false;
} }
@ -178,7 +180,7 @@ public class EntityParticle extends Entity implements IEntityAdditionalSpawnData
this.lastTurn--; this.lastTurn--;
/** Checks if the current block condition allows the particle to exist */ /** 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(); explode();
return; return;

View file

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.accelerator; package resonantinduction.atomic.machine.accelerator;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import resonant.lib.gui.GuiContainerBase; import resonant.lib.gui.GuiContainerBase;
@ -29,7 +29,7 @@ public class GuiAccelerator extends GuiContainerBase
Vector3 position = new Vector3(this.tileEntity); Vector3 position = new Vector3(this.tileEntity);
position.translate(this.tileEntity.getDirection().getOpposite()); 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."; 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; 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.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
@ -13,10 +14,12 @@ import resonant.api.IRotatable;
import resonant.lib.network.Synced; import resonant.lib.network.Synced;
import resonant.lib.prefab.tile.TileElectricalInventory; import resonant.lib.prefab.tile.TileElectricalInventory;
import resonantinduction.atomic.Atomic; 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.Reference;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings; import resonantinduction.core.Settings;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.electricity.IVoltageInput; import universalelectricity.api.electricity.IVoltageInput;
import universalelectricity.api.energy.EnergyStorageHandler; import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.energy.IEnergyInterface; import universalelectricity.api.energy.IEnergyInterface;
@ -56,6 +59,7 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
public TileAccelerator() public TileAccelerator()
{ {
super(UniversalElectricity.machine);
energy = new EnergyStorageHandler(energyPerTick * 2, energyPerTick / 20); energy = new EnergyStorageHandler(energyPerTick * 2, energyPerTick / 20);
maxSlots = 4; maxSlots = 4;
antiMatterDensityMultiplyer = DENSITY_MULTIPLYER_DEFAULT; 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). // Creates a accelerated particle if one needs to exist (on world load for example or player login).
if (getStackInSlot(0) != null && lastSpawnTick >= 40) if (getStackInSlot(0) != null && lastSpawnTick >= 40)
{ {
Vector3 spawnAcceleratedParticle = new Vector3(this); Vector3 spawn_vec = new Vector3(this);
spawnAcceleratedParticle.translate(getDirection().getOpposite()); spawn_vec.translate(getDirection().getOpposite());
spawnAcceleratedParticle.translate(0.5f); spawn_vec.translate(0.5f);
// Only render the particle if container within the proper environment for it. // 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. // Spawn the particle.
totalEnergyConsumed = 0; 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); worldObj.spawnEntityInWorld(entityParticle);
// Grabs input block hardness if available, otherwise defaults are used. // Grabs input block hardness if available, otherwise defaults are used.
@ -239,6 +243,16 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
lastSpawnTick++; 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() 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.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; 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.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import resonant.lib.gui.GuiContainerBase; import resonant.lib.gui.GuiContainerBase;
import resonantinduction.atomic.process.ContainerChemicalExtractor; import resonantinduction.atomic.machine.extractor.ContainerChemicalExtractor;
import resonantinduction.atomic.process.TileChemicalExtractor; import resonantinduction.atomic.machine.extractor.TileChemicalExtractor;
import universalelectricity.api.energy.UnitDisplay.Unit; import universalelectricity.api.energy.UnitDisplay.Unit;
public class GuiChemicalExtractor extends GuiContainerBase 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.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import resonant.lib.gui.GuiContainerBase; import resonant.lib.gui.GuiContainerBase;
import resonantinduction.atomic.fusion.ContainerNuclearBoiler; import resonantinduction.atomic.machine.plasma.ContainerNuclearBoiler;
import universalelectricity.api.energy.UnitDisplay.Unit; import universalelectricity.api.energy.UnitDisplay.Unit;
public class GuiNuclearBoiler extends GuiContainerBase 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.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; 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.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory; 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.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; 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.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; 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.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import resonant.lib.gui.GuiContainerBase; import resonant.lib.gui.GuiContainerBase;
import resonantinduction.atomic.machine.boiler.TileNuclearBoiler;
import universalelectricity.api.energy.UnitDisplay.Unit; import universalelectricity.api.energy.UnitDisplay.Unit;
public class GuiCentrifuge extends GuiContainerBase 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.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; 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.EntityPlayer;
import net.minecraft.inventory.ISidedInventory; 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.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; 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.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot; 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.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; 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.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory; 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.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry; 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.block.material.Material;
import net.minecraft.tileentity.TileEntity; 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.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; 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.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
@ -41,11 +41,11 @@ public class TileElectricTurbine extends TileTurbine implements IBoilHandler
@Override @Override
public void playSound() 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; double maxVelocity = (getMaxPower() / torque) * 4;
float percentage = angularVelocity * 4 / (float) maxVelocity; 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); 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.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; 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.ArrayList;
import java.util.HashSet; import java.util.HashSet;

View file

@ -1,4 +1,4 @@
package resonantinduction.atomic.particle.fulmination; package resonantinduction.atomic.machine.fulmination;
import java.util.EnumSet; 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.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer; 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.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; 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.SlotEnergyItem;
import resonant.lib.prefab.slot.SlotSpecific; import resonant.lib.prefab.slot.SlotSpecific;
import resonantinduction.atomic.Atomic; import resonantinduction.atomic.Atomic;
import resonantinduction.atomic.process.fission.TileNuclearBoiler; import resonantinduction.atomic.machine.boiler.TileNuclearBoiler;
/** Nuclear boiler container */ /** Nuclear boiler container */
public class ContainerNuclearBoiler extends ContainerBase 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.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;

View file

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

View file

@ -1,4 +1,4 @@
package resonantinduction.atomic.fusion; package resonantinduction.atomic.machine.plasma;
import java.util.HashMap; import java.util.HashMap;
@ -29,7 +29,7 @@ import com.google.common.io.ByteArrayDataInput;
public class TilePlasmaHeater extends TileElectrical implements IPacketReceiver, ITagRender, IFluidHandler public class TilePlasmaHeater extends TileElectrical implements IPacketReceiver, ITagRender, IFluidHandler
{ {
public static long DIAN = 10000000000L; public static long joules = 10000000000L;
@Config @Config
public static int plasmaHeatAmount = 100; public static int plasmaHeatAmount = 100;
@ -42,7 +42,7 @@ public class TilePlasmaHeater extends TileElectrical implements IPacketReceiver,
public TilePlasmaHeater() public TilePlasmaHeater()
{ {
energy = new EnergyStorageHandler(DIAN, DIAN / 20); energy = new EnergyStorageHandler(joules, joules / 20);
} }
@Override @Override
@ -67,11 +67,14 @@ public class TilePlasmaHeater extends TileElectrical implements IPacketReceiver,
{ {
if (energy.checkExtract()) 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); tankInputDeuterium.drain(plasmaHeatAmount, true);
tankInputTritium.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(); 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.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; 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.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation; 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.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem; 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.block.material.Material;
import net.minecraft.entity.item.EntityItem; 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.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase; 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.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import resonant.lib.gui.ContainerBase; import resonant.lib.gui.ContainerBase;
import resonant.lib.prefab.slot.SlotSpecific; import resonant.lib.prefab.slot.SlotSpecific;
import resonantinduction.atomic.fission.ItemBreederFuel; import resonantinduction.atomic.items.ItemBreederFuel;
import resonantinduction.atomic.fission.ItemFissileFuel; import resonantinduction.atomic.items.ItemFissileFuel;
public class ContainerReactorCell extends ContainerBase 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; 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.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; 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 net.minecraft.block.material.Material;
import resonant.lib.content.module.TileBlock; 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.ArrayList;
import java.util.List; import java.util.List;
@ -38,7 +38,7 @@ import resonant.lib.thermal.ThermalPhysics;
import resonant.lib.utility.inventory.InventoryUtility; import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.atomic.Atomic; import resonantinduction.atomic.Atomic;
import resonantinduction.atomic.ReactorExplosion; import resonantinduction.atomic.ReactorExplosion;
import resonantinduction.atomic.fusion.TilePlasma; import resonantinduction.atomic.machine.plasma.TilePlasma;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import universalelectricity.api.UniversalElectricity; import universalelectricity.api.UniversalElectricity;
@ -110,15 +110,9 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
{ {
TileReactorCell tile = getMultiBlock().get(); TileReactorCell tile = getMultiBlock().get();
if (!player.isSneaking()) if (player.inventory.getCurrentItem() != null)
{ {
if (tile.getStackInSlot(0) != 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 (player.inventory.getCurrentItem().getItem() instanceof IReactorComponent) if (player.inventory.getCurrentItem().getItem() instanceof IReactorComponent)
{ {
@ -130,8 +124,16 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
} }
} }
} }
else if (player.isSneaking() && tile.getStackInSlot(0) != null)
player.openGui(Atomic.INSTANCE, 0, world(), tile.xCoord, tile.yCoord, tile.zCoord); {
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; return true;
@ -214,8 +216,7 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
{ {
if (worldObj.rand.nextFloat() > 0.65) if (worldObj.rand.nextFloat() > 0.65)
{ {
List<EntityLiving> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, 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));
AxisAlignedBB.getBoundingBox(xCoord - RADIUS * 2, yCoord - RADIUS * 2, zCoord - RADIUS * 2, xCoord + RADIUS * 2, yCoord + RADIUS * 2, zCoord + RADIUS * 2));
for (EntityLiving entity : entities) for (EntityLiving entity : entities)
{ {
@ -276,7 +277,7 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
previousTemperature = temperature; previousTemperature = temperature;
//System.out.println("[Atomic Science] [Thermal Grid] Temperature: " + String.valueOf(previousTemperature)); //System.out.println("[Atomic Science] [Thermal Grid] Temperature: " + String.valueOf(previousTemperature));
} }
if (previousTemperature >= MELTING_POINT && meltdownCounter < meltdownCounterMaximum) if (previousTemperature >= MELTING_POINT && meltdownCounter < meltdownCounterMaximum)
{ {
shouldUpdate = true; shouldUpdate = true;
@ -290,7 +291,7 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
meltDown(); meltDown();
return; return;
} }
// Reset meltdown ticker to give the reactor more of a 'goldilocks zone'. // Reset meltdown ticker to give the reactor more of a 'goldilocks zone'.
if (previousTemperature < MELTING_POINT && meltdownCounter < meltdownCounterMaximum && meltdownCounter > 0) 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. // 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); 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 reactorExplosion = new ReactorExplosion(worldObj, null, xCoord, yCoord, zCoord, 9f);
reactorExplosion.doExplosionA(); reactorExplosion.doExplosionA();
reactorExplosion.doExplosionB(true); reactorExplosion.doExplosionB(true);
@ -514,7 +515,8 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
return 1; 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 @Override
public boolean canInsertItem(int slot, ItemStack items, int side) public boolean canInsertItem(int slot, ItemStack items, int side)
{ {
@ -583,8 +585,7 @@ public class TileReactorCell extends TileInventory implements IMultiBlockStructu
@Override @Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) public FluidTankInfo[] getTankInfo(ForgeDirection from)
{ {
return new FluidTankInfo[] return new FluidTankInfo[] { tank.getInfo() };
{ tank.getInfo() };
} }
@Override @Override

View file

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

View file

@ -1,4 +1,4 @@
package resonantinduction.atomic.process.sensor; package resonantinduction.atomic.machine.thermometer;
import java.util.List; 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.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; 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; 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; package resonantinduction.electrical.battery;
import static org.lwjgl.opengl.GL11.glPopMatrix; import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix; import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -21,14 +22,16 @@ import org.lwjgl.opengl.GL11;
import resonant.api.items.ISimpleItemRenderer; import resonant.api.items.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility; import resonant.lib.render.RenderUtility;
import resonant.lib.utility.WorldUtility;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
/** /**
* TODO: Make this more efficient.
*
* @author Calclavia * @author Calclavia
*
*/ */
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleItemRenderer 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); 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"); RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/battery.png");
List<String> disabledParts = new ArrayList<String>(); List<String> disabledParts = new ArrayList();
List<String> enabledParts = new ArrayList<String>(); List<String> enabledParts = new ArrayList();
for (ForgeDirection check : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection check : ForgeDirection.VALID_DIRECTIONS)
{ {
@ -128,6 +131,24 @@ public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleI
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
RenderUtility.rotateBlockBasedOnDirection(check); 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); GL11.glRotatef(-90, 0, 1, 0);
int io = tile.getIO(check); int io = tile.getIO(check);

View file

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

View file

@ -17,6 +17,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import resonant.api.event.LaserEvent; import resonant.api.event.LaserEvent;
import resonant.api.event.LaserFiredPlayerEvent;
import resonant.lib.prefab.vector.RayTraceHelper; import resonant.lib.prefab.vector.RayTraceHelper;
import resonant.lib.type.Pair; import resonant.lib.type.Pair;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
@ -120,7 +121,7 @@ public class ItemMiningLaser extends ItemEnergyTool
if (hit != null) if (hit != null)
{ {
LaserEvent event = new LaserEvent.LaserFiredPlayerEvent(player, hit, stack); LaserEvent event = new LaserFiredPlayerEvent(player, hit, stack);
MinecraftForge.EVENT_BUS.post(event); MinecraftForge.EVENT_BUS.post(event);
if (!player.worldObj.isRemote && !event.isCanceled()) 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.TileBreaker;
import resonantinduction.mechanical.process.edit.TilePlacer; import resonantinduction.mechanical.process.edit.TilePlacer;
import resonantinduction.mechanical.process.grinder.TileGrindingWheel; 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;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;

View file

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

View file

@ -1,29 +1,42 @@
package resonantinduction.mechanical.energy.grid; package resonantinduction.mechanical.energy.grid;
import java.io.IOException;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INode; import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider; import resonant.api.grid.INodeProvider;
import resonant.core.ResonantEngine;
import resonant.lib.References;
import resonant.lib.content.module.TileBase; import resonant.lib.content.module.TileBase;
import resonant.lib.network.IPacketReceiver; import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.IPacketReceiverWithID;
import resonant.lib.network.PacketHandler; import resonant.lib.network.PacketHandler;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.mechanical.Mechanical; import resonantinduction.mechanical.Mechanical;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import codechicken.multipart.ControlKeyModifer;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
/** Prefab for mechanical tiles /** Prefab for mechanical tiles
* *
* @author Calclavia */ * @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 */ /** Node that handles most mechanical actions */
public MechanicalNode mechanicalNode; public MechanicalNode mechanicalNode;
/** External debug GUI */
MechanicalNodeFrame frame = null;
@Deprecated @Deprecated
public TileMechanical() public TileMechanical()
@ -34,7 +47,7 @@ public abstract class TileMechanical extends TileBase implements INodeProvider,
public TileMechanical(Material material) public TileMechanical(Material material)
{ {
super(material); super(material);
mechanicalNode = new MechanicalNode(this).setLoad(0.5f); this.mechanicalNode = new MechanicalNode(this);
} }
@Override @Override
@ -56,11 +69,58 @@ public abstract class TileMechanical extends TileBase implements INodeProvider,
{ {
super.updateEntity(); super.updateEntity();
mechanicalNode.update(); mechanicalNode.update();
if (mechanicalNode.markRotationUpdate && ticks % 10 == 0)
if(frame != null)
{ {
sendRotationPacket(); frame.update();
mechanicalNode.markRotationUpdate = false; 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 @Override
@ -70,22 +130,46 @@ public abstract class TileMechanical extends TileBase implements INodeProvider,
return mechanicalNode; return mechanicalNode;
return null; return null;
} }
@Override
public Packet getDescriptionPacket()
{
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return References.PACKET_TILE.getPacketWithID(PACKET_NBT, this, tag);
}
private void sendRotationPacket() 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 @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); try
} {
if (world().isRemote)
public void onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra) {
{ if (id == PACKET_NBT)
if (id == PACKET_VELOCITY) {
mechanicalNode.angularVelocity = data.readDouble(); 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 @Override

View file

@ -11,6 +11,7 @@ import org.lwjgl.opengl.GL11;
import resonant.api.items.ISimpleItemRenderer; import resonant.api.items.ISimpleItemRenderer;
import resonant.lib.render.RenderUtility; import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; 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.glTranslatef((float) x + 0.5f, (float) y + 0.5f, (float) z + 0.5f);
GL11.glPushMatrix(); GL11.glPushMatrix();
// Determine if the turbine is facing horizontally or vertical.
RenderUtility.rotateBlockBasedOnDirectionUp(tile.getDirection()); 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) if (tile.getDirection().offsetY != 0)
{
renderWaterTurbine(tile.tier, tile.multiBlockRadius, tile.getMultiBlock().isConstructed()); renderWaterTurbine(tile.tier, tile.multiBlockRadius, tile.getMultiBlock().isConstructed());
}
else else
{
renderWaterWheel(tile.tier, tile.multiBlockRadius, tile.getMultiBlock().isConstructed()); renderWaterWheel(tile.tier, tile.multiBlockRadius, tile.getMultiBlock().isConstructed());
}
GL11.glPopMatrix(); GL11.glPopMatrix();
GL11.glPopMatrix(); GL11.glPopMatrix();

View file

@ -32,7 +32,8 @@ public class RenderWindTurbine extends TileEntitySpecialRenderer implements ISim
RenderUtility.rotateBlockBasedOnDirectionUp(tile.getDirection()); 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); GL11.glRotatef((float) Math.toDegrees(tile.mechanicalNode.renderAngle), 0, 1, 0);
render(tile.tier, tile.multiBlockRadius, tile.getMultiBlock().isConstructed()); render(tile.tier, tile.multiBlockRadius, tile.getMultiBlock().isConstructed());

View file

@ -1,35 +1,23 @@
package resonantinduction.mechanical.energy.turbine; package resonantinduction.mechanical.energy.turbine;
import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider; import resonant.api.grid.INodeProvider;
import resonant.lib.References;
import resonant.lib.content.module.TileBase;
import resonant.lib.multiblock.IMultiBlockStructure; import resonant.lib.multiblock.IMultiBlockStructure;
import resonant.lib.network.IPacketReceiverWithID; import resonant.lib.network.IPacketReceiverWithID;
import resonant.lib.network.PacketHandler; import resonantinduction.mechanical.energy.grid.TileMechanical;
import resonant.lib.network.Synced;
import resonant.lib.network.Synced.SyncedInput;
import resonant.lib.network.Synced.SyncedOutput;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
/** Reduced version of the main turbine class */ /** 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 */ /** Tier of the tile */
public int tier = 0; 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 */ /** The power of the turbine this tick. In joules/tick */
public long power = 0; public long power = 0;
protected final long defaultTorque = 5000; protected final long defaultTorque = 5000;
protected double prevAngularVelocity = 0;
/** Node that handles most of the mechanical connections */ /** MutliBlock methods. */
protected MechanicalNode mechanicalNode; private TurbineMBlockHandler multiBlock;
public TileTurbine() public TileTurbine()
{ {
@ -54,23 +42,10 @@ public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTu
mechanicalNode = new TurbineNode(this); mechanicalNode = new TurbineNode(this);
} }
public ForgeDirection getDirection()
{
return ForgeDirection.getOrientation(getBlockMetadata());
}
@Override
public void initiate()
{
mechanicalNode.reconstruct();
super.initiate();
}
@Override @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
mechanicalNode.update();
getMultiBlock().update(); getMultiBlock().update();
if (getMultiBlock().isPrimary()) if (getMultiBlock().isPrimary())
@ -79,12 +54,6 @@ public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTu
{ {
/** Set angular velocity based on power and torque. */ /** Set angular velocity based on power and torque. */
mechanicalNode.angularVelocity = (float) ((double) power / mechanicalNode.torque); mechanicalNode.angularVelocity = (float) ((double) power / mechanicalNode.torque);
if (ticks % 3 == 0 && prevAngularVelocity != mechanicalNode.angularVelocity)
{
sendPowerUpdate();
prevAngularVelocity = mechanicalNode.angularVelocity;
}
} }
if (mechanicalNode.angularVelocity != 0) if (mechanicalNode.angularVelocity != 0)
@ -116,42 +85,25 @@ public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTu
public void playSound() 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. */ /** Reads a tile entity from NBT. */
@Override @Override
@SyncedInput
public void readFromNBT(NBTTagCompound nbt) public void readFromNBT(NBTTagCompound nbt)
{ {
super.readFromNBT(nbt); super.readFromNBT(nbt);
multiBlockRadius = nbt.getInteger("multiBlockRadius"); multiBlockRadius = nbt.getInteger("multiBlockRadius");
tier = nbt.getInteger("tier"); tier = nbt.getInteger("tier");
mechanicalNode.load(nbt);
getMultiBlock().load(nbt); getMultiBlock().load(nbt);
} }
/** Writes a tile entity to NBT. */ /** Writes a tile entity to NBT. */
@Override @Override
@SyncedOutput
public void writeToNBT(NBTTagCompound nbt) public void writeToNBT(NBTTagCompound nbt)
{ {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setInteger("multiBlockRadius", multiBlockRadius); nbt.setInteger("multiBlockRadius", multiBlockRadius);
nbt.setInteger("tier", tier); nbt.setInteger("tier", tier);
mechanicalNode.save(nbt);
getMultiBlock().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); 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 @Override
public Vector3[] getMultiBlockVectors() public Vector3[] getMultiBlockVectors()
{ {
@ -216,44 +165,4 @@ public class TileTurbine extends TileBase implements IMultiBlockStructure<TileTu
{ {
return worldObj; 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.minecraft.world.IBlockAccess;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INodeProvider; import resonant.api.grid.INodeProvider;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings; import resonantinduction.core.Settings;
import resonantinduction.mechanical.energy.grid.MechanicalNode; import resonantinduction.mechanical.energy.grid.MechanicalNode;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.ReflectionHelper;
/** /**
* The vertical wind turbine collects airflow. * The vertical water turbine collects flowing water flowing on X axis.
* The horizontal wind turbine collects steam from steam power plants. * The horizontal water turbine collects flowing water on Z axis.
* *
* @author Calclavia * @author Calclavia
* *
@ -56,9 +57,13 @@ public class TileWaterTurbine extends TileTurbine
public void updateEntity() public void updateEntity()
{ {
if (getMultiBlock().isConstructed()) if (getMultiBlock().isConstructed())
{
mechanicalNode.torque = (long) (defaultTorque / (1d / multiBlockRadius)); mechanicalNode.torque = (long) (defaultTorque / (1d / multiBlockRadius));
}
else else
{
mechanicalNode.torque = defaultTorque / 12; mechanicalNode.torque = defaultTorque / 12;
}
/** /**
* If this is a horizontal turbine. * 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())); 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)) 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; mechanicalNode.torque = -mechanicalNode.torque;
}
if (getDirection().offsetX != 0) if (getDirection().offsetX != 0)
{
getMultiBlock().get().power += Math.abs(getWaterPower() * vector.z * (7 - metadata) / 7f); getMultiBlock().get().power += Math.abs(getWaterPower() * vector.z * (7 - metadata) / 7f);
powerTicks = 20;
}
if (getDirection().offsetZ != 0) if (getDirection().offsetZ != 0)
{
getMultiBlock().get().power += Math.abs(getWaterPower() * vector.x * (7 - metadata) / 7f); getMultiBlock().get().power += Math.abs(getWaterPower() * vector.x * (7 - metadata) / 7f);
powerTicks = 20;
}
} }
catch (Exception e) catch (Exception e)
{ {

View file

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

View file

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

View file

@ -1,9 +1,12 @@
package resonantinduction.mechanical.fluid.pipe; package resonantinduction.mechanical.fluid.pipe;
import net.minecraft.client.renderer.RenderBlocks; 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.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
@ -12,6 +15,7 @@ import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import resonant.api.grid.INode; import resonant.api.grid.INode;
import resonant.core.ResonantEngine;
import resonant.lib.type.EvictingList; import resonant.lib.type.EvictingList;
import resonant.lib.utility.WorldUtility; import resonant.lib.utility.WorldUtility;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
@ -19,12 +23,14 @@ import resonantinduction.core.grid.fluid.FluidPressureNode;
import resonantinduction.core.grid.fluid.IPressureNodeProvider; import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import resonantinduction.core.prefab.part.PartFramedNode; import resonantinduction.core.prefab.part.PartFramedNode;
import resonantinduction.mechanical.Mechanical; import resonantinduction.mechanical.Mechanical;
import resonantinduction.mechanical.energy.grid.MechanicalNodeFrame;
import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataInput;
import codechicken.lib.render.CCRenderState; import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.IconTransformation; import codechicken.lib.render.IconTransformation;
import codechicken.lib.render.RenderUtils; import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.Translation; import codechicken.lib.vec.Translation;
import codechicken.microblock.IHollowConnect; import codechicken.microblock.IHollowConnect;
import codechicken.multipart.ControlKeyModifer;
import codechicken.multipart.JNormalOcclusion; import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.TSlottedPart; import codechicken.multipart.TSlottedPart;
import cpw.mods.fml.relauncher.Side; 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. */ /** Computes the average fluid for client to render. */
private EvictingList<Integer> averageTankData = new EvictingList<Integer>(20); private EvictingList<Integer> averageTankData = new EvictingList<Integer>(20);
private boolean markPacket = true; private boolean markPacket = true;
private PipeNodeFrame frame = null;
public PartPipe() public PartPipe()
{ {
@ -81,6 +88,11 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, FluidPressureNode
{ {
sendFluidUpdate(); sendFluidUpdate();
markPacket = false; markPacket = false;
}
if (frame != null)
{
frame.update();
} }
} }
@ -220,4 +232,44 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, FluidPressureNode
public void onFluidChanged() 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; 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.TMultiPart;
import codechicken.multipart.TileMultipart; import codechicken.multipart.TileMultipart;
/** Node for the gear /**
* * Node for the gear
* @author Calclavia, Edited by: Darkguardsman */ *
* @author Calclavia, Edited by: Darkguardsman
*/
public class GearNode extends MechanicalNode public class GearNode extends MechanicalNode
{ {
public GearNode(PartGear parent) public GearNode(PartGear parent)
{ {
super(parent); super(parent);
} }
protected PartGear gear() protected PartGear gear()
{ {
return (PartGear) this.getParent(); return (PartGear) this.getParent();
} }
@Override @Override
public void onUpdate() public void onUpdate()
{ {
super.onUpdate(); super.onUpdate();
if (!gear().getMultiBlock().isPrimary()) if (!gear().getMultiBlock().isPrimary())
{ {
torque = 0; torque = 0;
angularVelocity = 0; angularVelocity = 0;
} }
else else
{ {
if (gear().tier == 10) if (gear().tier == 10)
{ {
torque = 100; torque = 100;
angularVelocity = 100; angularVelocity = 100;
} }
} }
} }
@Override @Override
public double getTorqueLoad() public double getTorqueLoad()
{ {
// Decelerate the gear based on tier. // Decelerate the gear based on tier.
switch (gear().tier) switch (gear().tier)
{ {
default: default:
return 0.3; return 0.3;
case 1: case 1:
return 0.2; return 0.2;
case 2: case 2:
return 0.1; return 0.1;
case 10: case 10:
return 0; return 0;
} }
} }
@Override @Override
public double getAngularVelocityLoad() public double getAngularVelocityLoad()
{ {
// Decelerate the gear based on tier. // Decelerate the gear based on tier.
switch (gear().tier) switch (gear().tier)
{ {
default: default:
return 0.03; return 0.03;
case 1: case 1:
return 0.02; return 0.02;
case 2: case 2:
return 0.01; return 0.01;
case 10: case 10:
return 0; return 0;
} }
} }
@Override @Override
public void recache() public void recache()
{ {
getConnections().clear(); synchronized (this)
{
getConnections().clear();
/** Only call refresh if this is the main block of a multiblock gear or a single gear block. */ /** Only call refresh if this is the main block of a multiblock gear or a single gear block. */
if (!gear().getMultiBlock().isPrimary() || world() == null) if (!gear().getMultiBlock().isPrimary() || world() == null)
{ {
return; return;
} }
/** Look for gears that are back-to-back with this gear. Equate torque. */ /** 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()); TileEntity tileBehind = new universalelectricity.api.vector.Vector3(gear().tile()).translate(gear().placementSide).getTileEntity(world());
if (tileBehind instanceof INodeProvider) if (tileBehind instanceof INodeProvider)
{ {
MechanicalNode instance = (MechanicalNode) ((INodeProvider) tileBehind).getNode(MechanicalNode.class, gear().placementSide.getOpposite()); 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)) if (instance != null && instance != this && !(instance.getParent() instanceof PartGearShaft) && instance.canConnect(gear().placementSide.getOpposite(), this))
{ {
getConnections().put(instance, gear().placementSide); getConnections().put(instance, gear().placementSide);
} }
} }
/** Look for gears that are internal and adjacent to this gear. (The 4 sides + the internal /** Look for gears that are internal and adjacent to this gear. (The 4 sides + the internal
* center) */ * center) */
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
ForgeDirection checkDir = ForgeDirection.getOrientation(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()) if (gear().getMultiBlock().isConstructed() && checkDir != gear().placementSide && checkDir != gear().placementSide.getOpposite())
{ {
tile = new universalelectricity.api.vector.Vector3(gear().tile()).translate(checkDir).getTileEntity(world()); tile = new universalelectricity.api.vector.Vector3(gear().tile()).translate(checkDir).getTileEntity(world());
} }
if (tile instanceof INodeProvider) if (tile instanceof INodeProvider)
{ {
/** If we're checking for the block that is opposite to the gear's placement side /** 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. */ * (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); 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)) if (!getConnections().containsValue(checkDir) && instance != this && checkDir != gear().placementSide && instance != null && instance.canConnect(checkDir.getOpposite(), this))
{ {
getConnections().put(instance, checkDir); getConnections().put(instance, checkDir);
} }
} }
} }
int displaceCheck = 1; int displaceCheck = 1;
if (gear().getMultiBlock().isPrimary() && gear().getMultiBlock().isConstructed()) if (gear().getMultiBlock().isPrimary() && gear().getMultiBlock().isConstructed())
{ {
displaceCheck = 2; displaceCheck = 2;
} }
/** Look for gears outside this block space, the relative UP, DOWN, LEFT, RIGHT */ /** Look for gears outside this block space, the relative UP, DOWN, LEFT, RIGHT */
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
ForgeDirection checkDir = ForgeDirection.getOrientation(Rotation.rotateSide(gear().placementSide.ordinal(), i)); ForgeDirection checkDir = ForgeDirection.getOrientation(Rotation.rotateSide(gear().placementSide.ordinal(), i));
TileEntity checkTile = new universalelectricity.api.vector.Vector3(gear().tile()).translate(checkDir, displaceCheck).getTileEntity(world()); TileEntity checkTile = new universalelectricity.api.vector.Vector3(gear().tile()).translate(checkDir, displaceCheck).getTileEntity(world());
if (!getConnections().containsValue(checkDir) && checkTile instanceof INodeProvider) if (!getConnections().containsValue(checkDir) && checkTile instanceof INodeProvider)
{ {
MechanicalNode instance = (MechanicalNode) ((INodeProvider) checkTile).getNode(MechanicalNode.class, gear().placementSide); MechanicalNode instance = (MechanicalNode) ((INodeProvider) checkTile).getNode(MechanicalNode.class, gear().placementSide);
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this) && !(instance.getParent() instanceof PartGearShaft)) if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this) && !(instance.getParent() instanceof PartGearShaft))
{ {
getConnections().put(instance, checkDir); getConnections().put(instance, checkDir);
} }
} }
} }
} }
}
/** Can this gear be connected BY the source? /**
* * Can this gear be connected BY the source?
* @param from - Direction source is coming from. *
* @param with - The source of the connection. * @param from - Direction source is coming from.
* @return True is so. */ * @param with - The source of the connection.
@Override * @return True is so.
public boolean canConnect(ForgeDirection from, Object with) */
{ @Override
if (!gear().getMultiBlock().isPrimary()) public boolean canConnect(ForgeDirection from, Object with)
{ {
return false; if (!gear().getMultiBlock().isPrimary())
} {
return false;
}
if (with instanceof MechanicalNode) if (with instanceof MechanicalNode)
{ {
INodeProvider parent = ((MechanicalNode) with).getParent(); INodeProvider parent = ((MechanicalNode) with).getParent();
/** Check for flat connections (gear face on gear face) to make sure it's actually on /** Check for flat connections (gear face on gear face) to make sure it's actually on
* this gear block. */ * this gear block. */
if (from == gear().placementSide.getOpposite()) if (from == gear().placementSide.getOpposite())
{ {
if (parent instanceof PartGear || parent instanceof PartGearShaft) if (parent instanceof PartGear || parent instanceof PartGearShaft)
{ {
if (parent instanceof PartGearShaft) if (parent instanceof PartGearShaft)
{ {
PartGearShaft shaft = (PartGearShaft) parent; 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); 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) else if (parent instanceof PartGear)
{ {
if (((PartGear) parent).tile() == gear().tile() && !gear().getMultiBlock().isConstructed()) if (((PartGear) parent).tile() == gear().tile() && !gear().getMultiBlock().isConstructed())
{ {
return true; return true;
} }
if (((PartGear) parent).placementSide != gear().placementSide) if (((PartGear) parent).placementSide != gear().placementSide)
{ {
TMultiPart part = gear().tile().partMap(((PartGear) parent).placementSide.ordinal()); TMultiPart part = gear().tile().partMap(((PartGear) parent).placementSide.ordinal());
if (part instanceof PartGear) if (part instanceof PartGear)
{ {
/** Case when we connect gears via edges internally. Large gear /** Case when we connect gears via edges internally. Large gear
* attempt to connect to small gear. */ * attempt to connect to small gear. */
PartGear sourceGear = (PartGear) part; PartGear sourceGear = (PartGear) part;
if (sourceGear.isCenterMultiBlock() && !sourceGear.getMultiBlock().isPrimary()) if (sourceGear.isCenterMultiBlock() && !sourceGear.getMultiBlock().isPrimary())
{ {
// For large gear to small gear on edge connection. // For large gear to small gear on edge connection.
return true; return true;
} }
} }
else else
{ {
/** Small gear attempting to connect to large gear. */ /** Small gear attempting to connect to large gear. */
if (gear().getMultiBlock().isConstructed()) if (gear().getMultiBlock().isConstructed())
{ {
TMultiPart checkPart = ((PartGear) parent).tile().partMap(gear().placementSide.ordinal()); TMultiPart checkPart = ((PartGear) parent).tile().partMap(gear().placementSide.ordinal());
if (checkPart instanceof PartGear) if (checkPart instanceof PartGear)
{ {
ForgeDirection requiredDirection = ((PartGear) checkPart).getPosition().subtract(position()).toForgeDirection(); ForgeDirection requiredDirection = ((PartGear) checkPart).getPosition().subtract(position()).toForgeDirection();
return ((PartGear) checkPart).isCenterMultiBlock() && ((PartGear) parent).placementSide == requiredDirection; return ((PartGear) checkPart).isCenterMultiBlock() && ((PartGear) parent).placementSide == requiredDirection;
} }
} }
} }
} }
} }
} }
/** Face to face stick connection. */ /** Face to face stick connection. */
TileEntity sourceTile = position().translate(from.getOpposite()).getTileEntity(world()); TileEntity sourceTile = position().translate(from.getOpposite()).getTileEntity(world());
if (sourceTile instanceof INodeProvider) if (sourceTile instanceof INodeProvider)
{ {
MechanicalNode sourceInstance = (MechanicalNode) ((INodeProvider) sourceTile).getNode(MechanicalNode.class, from); MechanicalNode sourceInstance = (MechanicalNode) ((INodeProvider) sourceTile).getNode(MechanicalNode.class, from);
return sourceInstance == with; return sourceInstance == with;
} }
} }
else if (from == gear().placementSide) else if (from == gear().placementSide)
{ {
/** Face to face stick connection. */ /** Face to face stick connection. */
TileEntity sourceTile = position().translate(from).getTileEntity(world()); TileEntity sourceTile = position().translate(from).getTileEntity(world());
if (sourceTile instanceof INodeProvider) if (sourceTile instanceof INodeProvider)
{ {
MechanicalNode sourceInstance = (MechanicalNode) ((INodeProvider) sourceTile).getNode(MechanicalNode.class, from.getOpposite()); MechanicalNode sourceInstance = (MechanicalNode) ((INodeProvider) sourceTile).getNode(MechanicalNode.class, from.getOpposite());
return sourceInstance == with; return sourceInstance == with;
} }
} }
else else
{ {
TileEntity destinationTile = ((MechanicalNode) with).position().translate(from.getOpposite()).getTileEntity(world()); TileEntity destinationTile = ((MechanicalNode) with).position().translate(from.getOpposite()).getTileEntity(world());
if (destinationTile instanceof INodeProvider && destinationTile instanceof TileMultipart) if (destinationTile instanceof INodeProvider && destinationTile instanceof TileMultipart)
{ {
TMultiPart destinationPart = ((TileMultipart) destinationTile).partMap(gear().placementSide.ordinal()); TMultiPart destinationPart = ((TileMultipart) destinationTile).partMap(gear().placementSide.ordinal());
if (destinationPart instanceof PartGear) if (destinationPart instanceof PartGear)
{ {
if (gear() != destinationPart) if (gear() != destinationPart)
{ {
return ((PartGear) destinationPart).isCenterMultiBlock(); return ((PartGear) destinationPart).isCenterMultiBlock();
} }
else else
{ {
return true; return true;
} }
} }
else else
{ {
return true; return true;
} }
} }
} }
} }
return false; return false;
} }
@Override @Override
public float getRatio(ForgeDirection dir, IMechanicalNode with) public float getRatio(ForgeDirection dir, IMechanicalNode with)
{ {
universalelectricity.api.vector.Vector3 deltaPos = with.position().subtract(position()); universalelectricity.api.vector.Vector3 deltaPos = with.position().subtract(position());
boolean caseX = gear().placementSide.offsetX != 0 && deltaPos.y == 0 && deltaPos.z == 0; boolean caseX = gear().placementSide.offsetX != 0 && deltaPos.y == 0 && deltaPos.z == 0;
boolean caseY = gear().placementSide.offsetY != 0 && deltaPos.x == 0 && deltaPos.z == 0; boolean caseY = gear().placementSide.offsetY != 0 && deltaPos.x == 0 && deltaPos.z == 0;
boolean caseZ = gear().placementSide.offsetZ != 0 && deltaPos.x == 0 && deltaPos.y == 0; boolean caseZ = gear().placementSide.offsetZ != 0 && deltaPos.x == 0 && deltaPos.y == 0;
if (caseX || caseY || caseZ) if (caseX || caseY || caseZ)
{ {
return super.getRatio(dir, with); 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.core.interfaces.IMechanicalNode;
import resonantinduction.mechanical.energy.grid.MechanicalNode; import resonantinduction.mechanical.energy.grid.MechanicalNode;
import resonantinduction.mechanical.gear.PartGear; import resonantinduction.mechanical.gear.PartGear;
import universalelectricity.api.vector.Vector3;
public class GearShaftNode extends MechanicalNode public class GearShaftNode extends MechanicalNode
{ {
public GearShaftNode(PartGearShaft parent) public GearShaftNode(PartGearShaft parent)
{ {
super(parent); super(parent);
} }
@Override @Override
public double getTorqueLoad() public double getTorqueLoad()
{ {
// Decelerate the gear based on tier. // Decelerate the gear based on tier.
switch (shaft().tier) switch (shaft().tier)
{ {
default: default:
return 0.03; return 0.03;
case 1: case 1:
return 0.02; return 0.02;
case 2: case 2:
return 0.01; return 0.01;
} }
} }
@Override @Override
public double getAngularVelocityLoad() public double getAngularVelocityLoad()
{ {
return 0; return 0;
} }
@Override @Override
public void recache() public void recache()
{ {
getConnections().clear(); synchronized (this)
List<ForgeDirection> dirs = new ArrayList<ForgeDirection>(); {
dirs.add(shaft().placementSide); getConnections().clear();
dirs.add(shaft().placementSide.getOpposite()); List<ForgeDirection> dirs = new ArrayList<ForgeDirection>();
/** Check for internal connections, the FRONT and BACK. */ dirs.add(shaft().placementSide);
Iterator<ForgeDirection> it = dirs.iterator(); dirs.add(shaft().placementSide.getOpposite());
while (it.hasNext()) /** Check for internal connections, the FRONT and BACK. */
{ Iterator<ForgeDirection> it = dirs.iterator();
ForgeDirection checkDir = it.next(); while (it.hasNext())
if (checkDir == shaft().placementSide || checkDir == shaft().placementSide.getOpposite()) {
{ ForgeDirection checkDir = it.next();
if (shaft().tile() instanceof INodeProvider) if (checkDir == shaft().placementSide || checkDir == shaft().placementSide.getOpposite())
{ {
MechanicalNode instance = (MechanicalNode) ((INodeProvider) shaft().tile()).getNode(MechanicalNode.class, checkDir); 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)) if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this))
{ {
getConnections().put(instance, checkDir); getConnections().put(instance, checkDir);
it.remove(); it.remove();
} }
} }
} }
} }
/** Look for connections outside this block space, the relative FRONT and BACK */ /** Look for connections outside this block space, the relative FRONT and BACK */
if (!dirs.isEmpty()) if (!dirs.isEmpty())
for (ForgeDirection checkDir : dirs) for (ForgeDirection checkDir : dirs)
{ {
if (!getConnections().containsValue(checkDir) && (checkDir == shaft().placementSide || checkDir == shaft().placementSide.getOpposite())) if (!getConnections().containsValue(checkDir) && (checkDir == shaft().placementSide || checkDir == shaft().placementSide.getOpposite()))
{ {
TileEntity checkTile = new universalelectricity.api.vector.Vector3(shaft().tile()).translate(checkDir).getTileEntity(world()); TileEntity checkTile = new Vector3(shaft().tile()).translate(checkDir).getTileEntity(world());
if (checkTile instanceof INodeProvider) if (checkTile instanceof INodeProvider)
{ {
MechanicalNode instance = (MechanicalNode) ((INodeProvider) checkTile).getNode(MechanicalNode.class, checkDir.getOpposite()); MechanicalNode instance = (MechanicalNode) ((INodeProvider) checkTile).getNode(MechanicalNode.class, checkDir.getOpposite());
// Only connect to shafts outside of this block space. // Only connect to shafts outside of this block space.
if (instance != null && instance != this && instance.getParent() instanceof PartGearShaft && instance.canConnect(checkDir.getOpposite(), this)) if (instance != null && instance != this && instance.getParent() instanceof PartGearShaft && instance.canConnect(checkDir.getOpposite(), this))
{ {
getConnections().put(instance, checkDir); getConnections().put(instance, checkDir);
} }
} }
} }
} }
} }
}
@Override @Override
public boolean canConnect(ForgeDirection from, Object source) public boolean canConnect(ForgeDirection from, Object source)
{ {
if (source instanceof MechanicalNode) if (source instanceof MechanicalNode)
{ {
if (((MechanicalNode) source).getParent() instanceof PartGear) if (((MechanicalNode) source).getParent() instanceof PartGear)
{ {
PartGear gear = (PartGear) ((MechanicalNode) source).getParent(); 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))) 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 false;
} }
} }
} }
return from == shaft().placementSide || from == shaft().placementSide.getOpposite(); return from == shaft().placementSide || from == shaft().placementSide.getOpposite();
} }
@Override @Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with) public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{ {
if (shaft().placementSide.offsetY != 0 || shaft().placementSide.offsetZ != 0) if (shaft().placementSide.offsetY != 0 || shaft().placementSide.offsetZ != 0)
{ {
return dir == shaft().placementSide.getOpposite(); return dir == shaft().placementSide.getOpposite();
} }
return dir == shaft().placementSide; return dir == shaft().placementSide;
} }
public PartGearShaft shaft() public PartGearShaft shaft()
{ {
return (PartGearShaft) this.getParent(); return (PartGearShaft) this.getParent();
} }
} }

View file

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

View file

@ -1,7 +1,7 @@
package resonantinduction.mechanical.process.crusher; 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.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -19,243 +19,243 @@ import resonantinduction.core.ResonantInduction;
import resonantinduction.mechanical.energy.grid.MechanicalNode; import resonantinduction.mechanical.energy.grid.MechanicalNode;
import resonantinduction.mechanical.energy.grid.TileMechanical; import resonantinduction.mechanical.energy.grid.TileMechanical;
import universalelectricity.api.vector.Vector3; 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 public class TileMechanicalPiston extends TileMechanical implements IRotatable
{ {
@Config @Config(comment = "Outdated, not used anymore. use mechanicalPistonMultiplier as its based on block hardness now")
private static int mechanicalPistonBreakCount = 5; @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() public TileMechanicalPiston()
{ {
super(Material.piston); super(Material.piston);
mechanicalNode = new MechanicalNode(this) mechanicalNode = new MechanicalNode(this)
{ {
@Override @Override
protected void revolve() protected void revolve()
{ {
markRevolve = true; markRevolve = true;
} }
@Override @Override
public boolean canConnect(ForgeDirection from, Object source) public boolean canConnect(ForgeDirection from, Object source)
{ {
return from != getDirection(); return from != getDirection();
} }
}.setLoad(0.5f); }.setLoad(0.5f);
isOpaqueCube = false; isOpaqueCube = false;
normalRender = false; normalRender = false;
customItemRender = true; customItemRender = true;
rotationMask = Byte.parseByte("111111", 2); rotationMask = Byte.parseByte("111111", 2);
textureName = "material_steel_dark"; textureName = "material_steel_dark";
} }
@Override @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
if (markRevolve) if (markRevolve)
{ {
Vector3 movePosition = new Vector3(TileMechanicalPiston.this).translate(getDirection()); Vector3 movePosition = new Vector3(TileMechanicalPiston.this).translate(getDirection());
if (!hitOreBlock(movePosition)) if (!hitOreBlock(movePosition))
{ {
if (!worldObj.isRemote) if (!worldObj.isRemote)
{ {
Vector3 moveNewPosition = movePosition.clone().translate(getDirection()); Vector3 moveNewPosition = movePosition.clone().translate(getDirection());
if (canMove(movePosition, moveNewPosition)) if (canMove(movePosition, moveNewPosition))
move(movePosition, moveNewPosition); {
} move(movePosition, moveNewPosition);
} }
}
}
markRevolve = false; markRevolve = false;
} }
} }
public boolean hitOreBlock(Vector3 blockPos) public boolean hitOreBlock(Vector3 blockPos)
{ {
Block block = Block.blocksList[blockPos.getBlockID(world())]; Block block = Block.blocksList[blockPos.getBlockID(world())];
if (block != null) if (block != null)
{ {
ItemStack blockStack = new ItemStack(block); int breakCount = (int) (mechanicalPistonMultiplier * block.blockHardness);
RecipeResource[] resources = MachineRecipes.INSTANCE.getOutput(ResonantInduction.RecipeType.CRUSHER.name(), blockStack); final int startBreakCount = breakCount;
if (resources.length > 0) ItemStack blockStack = new ItemStack(block);
{ RecipeResource[] resources = MachineRecipes.INSTANCE.getOutput(ResonantInduction.RecipeType.CRUSHER.name(), blockStack);
if (!worldObj.isRemote)
{
int breakStatus = (int) (((float) (mechanicalPistonBreakCount - breakCount) / (float) mechanicalPistonBreakCount) * 10f);
world().destroyBlockInWorldPartially(0, blockPos.intX(), blockPos.intY(), blockPos.intZ(), breakStatus);
if (breakCount <= 0) if (resources.length > 0)
{ {
if (!world().isRemote) if (!worldObj.isRemote)
{ {
for (RecipeResource recipe : resources) int breakStatus = (int) (((float) (startBreakCount - breakCount) / (float) startBreakCount) * 10f);
{ world().destroyBlockInWorldPartially(0, blockPos.intX(), blockPos.intY(), blockPos.intZ(), breakStatus);
if (Math.random() <= recipe.getChance()) ResonantInduction.LOGGER.info("[Mechanical Piston] Break Count: " + breakCount);
{
InventoryUtility.dropItemStack(world(), blockPos.clone().translate(0.5), recipe.getItemStack(), 10, 0); 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); if (!worldObj.isRemote)
breakCount--; {
return true; 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) public boolean canMove(Vector3 from, Vector3 to)
world().destroyBlockInWorldPartially(0, blockPos.intX(), blockPos.intY(), blockPos.intZ(), -1); {
return false; TileEntity tileEntity = from.getTileEntity(worldObj);
}
@Override if (this.equals(to.getTileEntity(getWorldObj())))
public void onRemove(int par5, int par6) {
{ return false;
super.onRemove(par5, par6); }
}
public boolean canMove(Vector3 from, Vector3 to) /** Check Target */
{ int targetBlockID = to.getBlockID(worldObj);
TileEntity tileEntity = from.getTileEntity(worldObj);
if (this.equals(to.getTileEntity(getWorldObj()))) if (!(worldObj.isAirBlock(to.intX(), to.intY(), to.intZ()) || (targetBlockID > 0 && (Block.blocksList[targetBlockID].isBlockReplaceable(worldObj, to.intX(), to.intY(), to.intZ())))))
{ {
return false; return false;
} }
/** Check Target */ return true;
int targetBlockID = to.getBlockID(worldObj); }
if (!(worldObj.isAirBlock(to.intX(), to.intY(), to.intZ()) || (targetBlockID > 0 && (Block.blocksList[targetBlockID].isBlockReplaceable(worldObj, to.intX(), to.intY(), to.intZ()))))) public void move(Vector3 from, Vector3 to)
{ {
return false; int blockID = from.getBlockID(worldObj);
} int blockMetadata = from.getBlockMetadata(worldObj);
return true; TileEntity tileEntity = from.getTileEntity(worldObj);
}
public void move(Vector3 from, Vector3 to) NBTTagCompound tileData = new NBTTagCompound();
{
int blockID = from.getBlockID(worldObj);
int blockMetadata = from.getBlockMetadata(worldObj);
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) if (tileEntity != null && tileData != null)
{ {
tileEntity.writeToNBT(tileData); /** 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) if (isMultipart)
{ {
/** try
* Forge Multipart Support. Use FMP's custom TE creator. {
*/ Class multipart = Class.forName("codechicken.multipart.MultipartHelper");
boolean isMultipart = tileData.getString("id").equals("savedMultipart"); 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) if (newTile != null && isMultipart)
{ {
try try
{ {
Class multipart = Class.forName("codechicken.multipart.MultipartHelper"); // Send the description packet of the TE after moving it.
Method m = multipart.getMethod("createTileFromNBT", World.class, NBTTagCompound.class); Class multipart = Class.forName("codechicken.multipart.MultipartHelper");
newTile = (TileEntity) m.invoke(null, worldObj, tileData); multipart.getMethod("sendDescPacket", World.class, TileEntity.class).invoke(null, worldObj, newTile);
}
catch (Exception e)
{
e.printStackTrace();
}
}
else
{
newTile = TileEntity.createAndLoadEntity(tileData);
}
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) notifyChanges(from);
{ notifyChanges(to);
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);
// Call onMoved event. public void notifyChanges(Vector3 pos)
Class tileMultipart = Class.forName("codechicken.multipart.TileMultipart"); {
tileMultipart.getMethod("onMoved").invoke(newTile); worldObj.notifyBlocksOfNeighborChange(pos.intX(), pos.intY(), pos.intZ(), pos.getBlockID(worldObj));
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
else
{
MovementUtility.setBlockSneaky(worldObj, to, blockID, blockMetadata, null);
}
notifyChanges(from); TileEntity newTile = pos.getTileEntity(worldObj);
notifyChanges(to);
}
public void notifyChanges(Vector3 pos) if (newTile != null)
{ {
worldObj.notifyBlocksOfNeighborChange(pos.intX(), pos.intY(), pos.intZ(), pos.getBlockID(worldObj)); if (Loader.isModLoaded("BuildCraft|Factory"))
{
/** Special quarry compatibility code. */
try
{
Class clazz = Class.forName("buildcraft.factory.TileQuarry");
TileEntity newTile = pos.getTileEntity(worldObj); if (newTile.equals(clazz))
{
if (newTile != null) ReflectionHelper.setPrivateValue(clazz, newTile, true, "isAlive");
{ }
if (Loader.isModLoaded("BuildCraft|Factory")) }
{ catch (Exception e)
/** {
* Special quarry compatibility code. e.printStackTrace();
*/ }
try }
{ }
Class clazz = Class.forName("buildcraft.factory.TileQuarry"); }
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); glTranslatef((float) x + 0.5F, (float) y + 0.5f, (float) z + 0.5F);
glScalef(0.51f, 0.5f, 0.5f); glScalef(0.51f, 0.5f, 0.5f);
ForgeDirection dir = tile.getDirection(); 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); RenderUtility.rotateBlockBasedOnDirection(dir);
glRotatef((float) Math.toDegrees(tile.mechanicalNode.renderAngle), 0, 0, 1); glRotatef((float) Math.toDegrees(tile.mechanicalNode.renderAngle), 0, 0, 1);
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png"); 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.IRotatable;
import resonant.api.recipe.MachineRecipes; import resonant.api.recipe.MachineRecipes;
import resonant.api.recipe.RecipeResource; import resonant.api.recipe.RecipeResource;
import resonant.lib.prefab.CustomDamageSource;
import resonant.lib.prefab.vector.Cuboid; import resonant.lib.prefab.vector.Cuboid;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
@ -22,43 +23,24 @@ import universalelectricity.api.vector.Vector3;
/** /**
* @author Calclavia * @author Calclavia
*
*/ */
public class TileGrindingWheel extends TileMechanical implements IRotatable public class TileGrindingWheel extends TileMechanical implements IRotatable
{ {
public static final int PROCESS_TIME = 20 * 20; 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; public EntityItem grindingItem = null;
private final long requiredTorque = 1000; private final long requiredTorque = 250;
private double counter = 0; private double counter = 0;
public TileGrindingWheel() public TileGrindingWheel()
{ {
super(Material.rock); super(Material.rock);
mechanicalNode = new GrinderNode(this).setLoad(2);
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);
bounds = new Cuboid(0.05f, 0.05f, 0.05f, 0.95f, 0.95f, 0.95f); bounds = new Cuboid(0.05f, 0.05f, 0.05f, 0.95f, 0.95f, 0.95f);
isOpaqueCube = false; isOpaqueCube = false;
normalRender = false; normalRender = false;
@ -67,6 +49,14 @@ public class TileGrindingWheel extends TileMechanical implements IRotatable
textureName = "material_steel_dark"; textureName = "material_steel_dark";
} }
@Override
public void updateEntity()
{
super.updateEntity();
counter = Math.max(counter + Math.abs(mechanicalNode.torque), 0);
doWork();
}
@Override @Override
public void collide(Entity entity) public void collide(Entity entity)
{ {
@ -98,7 +88,7 @@ public class TileGrindingWheel extends TileMechanical implements IRotatable
} }
else 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(); ForgeDirection dir = getDirection();
dir = ForgeDirection.getOrientation(!(dir.ordinal() % 2 == 0) ? dir.ordinal() - 1 : dir.ordinal()).getOpposite(); dir = ForgeDirection.getOrientation(!(dir.ordinal() % 2 == 0) ? dir.ordinal() - 1 : dir.ordinal()).getOpposite();
double speed = mechanicalNode.getAngularSpeed() / 20; 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? * Can this machine work this tick?
* *
* @return * @return
*/ */
public boolean canWork() 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.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix; 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.LinkedHashSet;
import java.util.List; import java.util.List;
@ -41,17 +41,7 @@ public class TileMixer extends TileMechanical implements IInventory
public TileMixer() public TileMixer()
{ {
super(Material.iron); super(Material.iron);
mechanicalNode = new MixerNode(this).setConnection(Byte.parseByte("000011", 2));
mechanicalNode = new MechanicalNode(this)
{
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
return dir == ForgeDirection.DOWN;
}
}.setConnection(Byte.parseByte("000011", 2));
isOpaqueCube = false; isOpaqueCube = false;
normalRender = false; normalRender = false;
customItemRender = true; customItemRender = true;

View file

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

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