Skip to content

Commit

Permalink
Smeltery Gigantus Networkus Transmissus
Browse files Browse the repository at this point in the history
  • Loading branch information
mDiyo committed Oct 6, 2013
1 parent 0dbf245 commit d99350d
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 92 deletions.
4 changes: 0 additions & 4 deletions src/tconstruct/TConstruct.java
Expand Up @@ -128,10 +128,6 @@ public void preInit (FMLPreInitializationEvent event)
VillagerRegistry.instance().registerVillageCreationHandler(new VillageSmelteryHandler());
try
{
//if (MinecraftServer.getServer().getMinecraftVersion().equals("1.6.4"))
/*ComparableVersion cv = new ComparableVersion(new CallableMinecraftVersion(null).minecraftVersion());
ComparableVersion compare = new ComparableVersion("1.6.4");
if (compare.compareTo(cv) > 0)*///<-- Probably not right
if (new CallableMinecraftVersion(null).minecraftVersion().equals("1.6.4"))
{
MapGenStructureIO.func_143031_a(ComponentToolWorkshop.class, "TConstruct:ToolWorkshopStructure");
Expand Down
6 changes: 4 additions & 2 deletions src/tconstruct/blocks/SmelteryBlock.java
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.AdaptiveSmelteryLogic;
import tconstruct.blocks.logic.MultiServantLogic;
import tconstruct.blocks.logic.SmelteryDrainLogic;
import tconstruct.blocks.logic.SmelteryLogic;
Expand Down Expand Up @@ -138,7 +139,8 @@ public int quantityDropped (Random random)
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
return TConstruct.proxy.smelteryGuiID;
return -1;
//return TConstruct.proxy.smelteryGuiID;
}

public void randomDisplayTick (World world, int x, int y, int z, Random random)
Expand Down Expand Up @@ -214,7 +216,7 @@ public TileEntity createTileEntity (World world, int metadata)
switch (metadata)
{
case 0:
return new SmelteryLogic();
return new AdaptiveSmelteryLogic();
case 1:
return new SmelteryDrainLogic();
case 3:
Expand Down
4 changes: 3 additions & 1 deletion src/tconstruct/blocks/component/SmelteryScan.java
Expand Up @@ -51,13 +51,15 @@ protected boolean checkServant (int x, int y, int z)
protected void addAirBlock (int x, int y, int z)
{
super.addAirBlock(x, y, z);
world.setBlock(x, y, z, Block.leaves.blockID);
world.setBlock(x, y, z, Block.glass.blockID);
}

public void cleanup()
{
System.out.println("Structure cleanup activated. Air blocks: "+airCoords.size());
super.cleanup();

//Temporary
Iterator i = airCoords.iterator();
while (i.hasNext())
{
Expand Down
131 changes: 83 additions & 48 deletions src/tconstruct/blocks/logic/AdaptiveSmelteryLogic.java
Expand Up @@ -22,6 +22,7 @@
import tconstruct.library.component.IComponentHolder;
import tconstruct.library.component.LogicComponent;
import tconstruct.library.component.MultiFluidTank;
import tconstruct.library.util.CoordTuple;
import tconstruct.library.util.IActiveLogic;
import tconstruct.library.util.IMasterLogic;
import tconstruct.library.util.IServantLogic;
Expand All @@ -41,29 +42,37 @@ public void updateEntity ()
if (tick % 4 == 0)
smeltery.heatItems();

if (tick % 20 == 0)
if (tick % 20 == 0 && structure.isComplete())
{
smeltery.update();
}

if (tick >= 60)
{
if (!structure.isComplete())
{
structure.checkValidStructure();
if (structure.isComplete())
{
smeltery.adjustSize(structure.getAirSize(), true);
multitank.setCapacity(structure.getAirSize() * (TConstruct.ingotLiquidValue * 18));
validateSmeltery();
}
}
else
{
smeltery.update();
}
}

if (tick == 60)
{
tick = 0;
}
}

@Override
public List<LogicComponent> getComponents ()
{
ArrayList<LogicComponent> ret = new ArrayList<LogicComponent>(3);
ret.add(structure);
ret.add(multitank);
ret.add(smeltery);
return ret;
}

/* Structure */

@Override
public void setWorldObj (World world)
{
Expand All @@ -72,6 +81,37 @@ public void setWorldObj (World world)
smeltery.setWorld(world);
}

@Override
public void notifyChange (IServantLogic servant, int x, int y, int z)
{

}

@Override
public void placeBlock (EntityLivingBase entity, ItemStack itemstack)
{
structure.checkValidStructure();
if (structure.isComplete())
{
validateSmeltery();
}
}

void validateSmeltery()
{
adjustInventory(structure.getAirSize(), true);
smeltery.adjustSize(structure.getAirSize(), true);
multitank.setCapacity(structure.getAirSize() * (TConstruct.ingotLiquidValue * 18));
}

@Override
public void removeBlock ()
{
structure.cleanup();
}

/* Direction */

@Override
public byte getRenderDirection ()
{
Expand Down Expand Up @@ -125,81 +165,76 @@ public void setActive (boolean flag)
{

}


/* Inventory */

@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
public int getInventoryStackLimit ()
{
return null;
return 1;
}

@Override
public String getDefaultName ()
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
return "crafters.Smeltery";
}

@Override
public List<LogicComponent> getComponents ()
{
ArrayList<LogicComponent> ret = new ArrayList<LogicComponent>(3);
ret.add(structure);
ret.add(multitank);
ret.add(smeltery);
return ret;
inventory[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
{
itemstack.stackSize = getInventoryStackLimit();
updateAirBlocks(slot, itemstack);
}
}

@Override
public void notifyChange (IServantLogic servant, int x, int y, int z)
void updateAirBlocks (int slot, ItemStack itemstack)
{

//CoordTuple coord = structure.airCoords.;
}

@Override
public void placeBlock (EntityLivingBase entity, ItemStack itemstack)
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
structure.checkValidStructure();
if (structure.isComplete())
{
smeltery.adjustSize(structure.getAirSize(), true);
multitank.setCapacity(structure.getAirSize() * (TConstruct.ingotLiquidValue * 18));
}
return null;
}

@Override
public void removeBlock ()
public String getDefaultName ()
{
structure.cleanup();
return "crafters.Smeltery";
}

/* Network */

@Override
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
readNetworkNBT(tags);

structure.readFromNBT(tags);
multitank.readFromNBT(tags);
smeltery.readFromNBT(tags);
}

public void readNetworkNBT (NBTTagCompound tags)
{
direction = tags.getByte("Direction");

structure.readNetworkNBT(tags);
multitank.readNetworkNBT(tags);
smeltery.readNetworkNBT(tags);
}

@Override
public void writeToNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
writeNetworkNBT(tags);

structure.writeToNBT(tags);
multitank.writeToNBT(tags);
smeltery.writeToNBT(tags);
}

public void readNetworkNBT (NBTTagCompound tags)
{
direction = tags.getByte("Direction");

structure.readNetworkNBT(tags);
multitank.readNetworkNBT(tags);
smeltery.readNetworkNBT(tags);
}

public void writeNetworkNBT (NBTTagCompound tags)
{
tags.setByte("Direction", direction);
Expand Down
3 changes: 2 additions & 1 deletion src/tconstruct/common/TContent.java
Expand Up @@ -444,7 +444,8 @@ void registerBlocks()
liquidMetal = new MaterialLiquid(MapColor.tntColor);

moltenIronFluid = new Fluid("fluid.iron.molten");
FluidRegistry.registerFluid(moltenIronFluid);
if (!FluidRegistry.registerFluid(moltenIronFluid))
moltenIronFluid = FluidRegistry.getFluid("fluid.iron.molten");
moltenIron = new LiquidMetalFinite(PHConstruct.moltenIron, moltenIronFluid, "liquid_iron").setUnlocalizedName("metal.molten.iron");
GameRegistry.registerBlock(moltenIron, "metal.molten.iron");
moltenIronFluid.setBlockID(moltenIron).setLuminosity(12).setDensity(3000).setViscosity(6000);
Expand Down
14 changes: 7 additions & 7 deletions src/tconstruct/library/component/LogicComponent.java
Expand Up @@ -14,21 +14,21 @@ public void setWorld(World world)

public void readFromNBT (NBTTagCompound tags)
{

}

public void writeToNBT (NBTTagCompound tags)
{

readNetworkNBT(tags);
}

public void readNetworkNBT (NBTTagCompound tags)
{

}

public void writeToNBT (NBTTagCompound tags)
{
writeNetworkNBT(tags);
}

public void writeNetworkNBT (NBTTagCompound tags)
{

}
}
}

0 comments on commit d99350d

Please sign in to comment.