Structural Glass is now real, started on core turbine multiblock code

This commit is contained in:
aidancbrady 2016-01-22 15:41:34 -05:00
parent bb9c203fae
commit 0c025e1033
22 changed files with 462 additions and 112 deletions

View file

@ -167,6 +167,7 @@ import mekanism.common.tile.TileEntityRotaryCondensentrator;
import mekanism.common.tile.TileEntitySeismicVibrator;
import mekanism.common.tile.TileEntitySolarEvaporationController;
import mekanism.common.tile.TileEntitySolarNeutronActivator;
import mekanism.common.tile.TileEntityStructuralGlass;
import mekanism.common.tile.TileEntityTeleporter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
@ -328,6 +329,7 @@ public class ClientProxy extends CommonProxy
GameRegistry.registerTileEntity(TileEntityInductionCell.class, "InductionCell");
GameRegistry.registerTileEntity(TileEntityInductionProvider.class, "InductionProvider");
GameRegistry.registerTileEntity(TileEntityOredictionificator.class, "Oredictionificator");
GameRegistry.registerTileEntity(TileEntityStructuralGlass.class, "StructuralGlass");
}
@Override

View file

@ -104,6 +104,7 @@ import mekanism.common.tile.TileEntityRotaryCondensentrator;
import mekanism.common.tile.TileEntitySeismicVibrator;
import mekanism.common.tile.TileEntitySolarEvaporationController;
import mekanism.common.tile.TileEntitySolarNeutronActivator;
import mekanism.common.tile.TileEntityStructuralGlass;
import mekanism.common.tile.TileEntityTeleporter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@ -189,6 +190,7 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileEntityInductionCell.class, "InductionCell");
GameRegistry.registerTileEntity(TileEntityInductionProvider.class, "InductionProvider");
GameRegistry.registerTileEntity(TileEntityOredictionificator.class, "Oredictionificator");
GameRegistry.registerTileEntity(TileEntityStructuralGlass.class, "StructuralGlass");
}
public void handleTeleporterUpdate(PortableTeleporterMessage message) {}

View file

@ -47,7 +47,6 @@ import mekanism.common.content.matrix.SynchronizedMatrixData;
import mekanism.common.content.tank.SynchronizedTankData;
import mekanism.common.content.transporter.PathfinderCache;
import mekanism.common.content.transporter.TransporterManager;
import mekanism.common.content.turbine.SynchronizedTurbineData;
import mekanism.common.entity.EntityBabySkeleton;
import mekanism.common.entity.EntityBalloon;
import mekanism.common.entity.EntityFlame;
@ -171,7 +170,6 @@ public class Mekanism
/** MultiblockManagers for various structrures */
public static MultiblockManager<SynchronizedTankData> tankManager = new MultiblockManager<SynchronizedTankData>("dynamicTank");
public static MultiblockManager<SynchronizedMatrixData> matrixManager = new MultiblockManager<SynchronizedMatrixData>("inductionMatrix");
public static MultiblockManager<SynchronizedTurbineData> turbineManager = new MultiblockManager<SynchronizedTurbineData>("industrialTurbine");
public static MultiblockManager<SynchronizedBoilerData> boilerManager = new BoilerManager("thermoelectricBoiler");
/** FrequencyManagers for various networks */

View file

@ -1,11 +1,10 @@
package mekanism.common.block;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import mekanism.api.Coord4D;
import mekanism.api.Range4D;
import mekanism.api.energy.IEnergizedItem;
import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.client.render.MekanismRenderer;
@ -22,8 +21,21 @@ import mekanism.common.base.IBoundingBlock;
import mekanism.common.content.tank.TankUpdateProtocol;
import mekanism.common.inventory.InventoryBin;
import mekanism.common.item.ItemBlockBasic;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tile.*;
import mekanism.common.multiblock.IMultiblock;
import mekanism.common.multiblock.IStructuralMultiblock;
import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.tile.TileEntityBin;
import mekanism.common.tile.TileEntityDynamicTank;
import mekanism.common.tile.TileEntityDynamicValve;
import mekanism.common.tile.TileEntityInductionCasing;
import mekanism.common.tile.TileEntityInductionCell;
import mekanism.common.tile.TileEntityInductionPort;
import mekanism.common.tile.TileEntityInductionProvider;
import mekanism.common.tile.TileEntityMultiblock;
import mekanism.common.tile.TileEntitySolarEvaporationBlock;
import mekanism.common.tile.TileEntitySolarEvaporationController;
import mekanism.common.tile.TileEntitySolarEvaporationValve;
import mekanism.common.tile.TileEntityStructuralGlass;
import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -46,11 +58,10 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Block class for handling multiple metal block IDs.
@ -64,7 +75,7 @@ import java.util.Random;
* 0:7: Teleporter Frame
* 0:8: Steel Casing
* 0:9: Dynamic Tank
* 0:10: Dynamic Glass
* 0:10: Structural Glass
* 0:11: Dynamic Valve
* 0:12: Copper Block
* 0:13: Tin Block
@ -128,6 +139,11 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
{
((TileEntityBasicBlock)tileEntity).onNeighborChange(block);
}
if(tileEntity instanceof IStructuralMultiblock)
{
((IStructuralMultiblock)tileEntity).update();
}
}
}
@ -526,24 +542,13 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
return true;
}
else if(metadata == 9 || metadata == 10 || metadata == 11)
else if(metadata == 9 || metadata == 11)
{
if(!entityplayer.isSneaking() && ((TileEntityDynamicTank)world.getTileEntity(x, y, z)).structure != null)
{
TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)world.getTileEntity(x, y, z);
if(!manageInventory(entityplayer, tileEntity))
{
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity)));
entityplayer.openGui(Mekanism.instance, 18, world, x, y, z);
}
else {
entityplayer.inventory.markDirty();
tileEntity.sendPacketToRenderer();
}
return true;
}
return ((IMultiblock)world.getTileEntity(x, y, z)).onActivate(entityplayer);
}
else if(metadata == 10)
{
return ((IStructuralMultiblock)world.getTileEntity(x, y, z)).onActivate(entityplayer);
}
}
else if(blockType == BasicBlock.BASIC_BLOCK_2)
@ -555,15 +560,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
if(metadata == 1 || metadata == 2)
{
if(!entityplayer.isSneaking() && ((TileEntityInductionCasing)world.getTileEntity(x, y, z)).structure != null)
{
TileEntityInductionCasing tileEntity = (TileEntityInductionCasing)world.getTileEntity(x, y, z);
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity)));
entityplayer.openGui(Mekanism.instance, 49, world, x, y, z);
return true;
}
return ((IMultiblock)world.getTileEntity(x, y, z)).onActivate(entityplayer);
}
}
@ -576,7 +573,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
return !(blockType == BasicBlock.BASIC_BLOCK_1 && world.getBlockMetadata(x, y, z) == 10);
}
private boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity)
public static boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity)
{
ItemStack itemStack = player.getCurrentEquippedItem();
@ -808,7 +805,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
case 9:
return new TileEntityDynamicTank();
case 10:
return new TileEntityDynamicTank();
return new TileEntityStructuralGlass();
case 11:
return new TileEntityDynamicValve();
case 14:
@ -893,6 +890,11 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
{
((TileEntityMultiblock)tileEntity).update();
}
if(tileEntity instanceof IStructuralMultiblock)
{
((IStructuralMultiblock)tileEntity).update();
}
}
}

View file

@ -1,6 +0,0 @@
package mekanism.common.content.turbine;
public class TurbineUpdateProtocol
{
}

View file

@ -1,7 +1,8 @@
package mekanism.common.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.api.Range4D;
@ -28,9 +29,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Item class for handling multiple metal block IDs.
@ -44,7 +44,7 @@ import java.util.List;
* 0:7: Teleporter Frame
* 0:8: Steel Casing
* 0:9: Dynamic Tank
* 0:10: Dynamic Glass
* 0:10: Structural Glass
* 0:11: Dynamic Valve
* 0:12: Copper Block
* 0:13: Tin Block
@ -306,7 +306,7 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem
name = "DynamicTank";
break;
case 10:
name = "DynamicGlass";
name = "StructuralGlass";
break;
case 11:
name = "DynamicValve";

View file

@ -1,6 +1,12 @@
package mekanism.common.multiblock;
import net.minecraft.entity.player.EntityPlayer;
public interface IMultiblock<T extends SynchronizedData<T>>
{
public T getSynchronizedData();
public boolean onActivate(EntityPlayer player);
public void update();
}

View file

@ -0,0 +1,17 @@
package mekanism.common.multiblock;
import mekanism.api.Coord4D;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
public interface IStructuralMultiblock
{
public boolean onActivate(EntityPlayer player);
public boolean canInterface(TileEntity controller);
public void setController(Coord4D coord);
public void update();
}

View file

@ -6,7 +6,6 @@ import java.util.List;
import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.common.Mekanism;
import mekanism.common.tile.TileEntityMultiblock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -16,7 +15,7 @@ import net.minecraftforge.common.util.ForgeDirection;
public abstract class UpdateProtocol<T extends SynchronizedData<T>>
{
/** The multiblock nodes that have already been iterated over. */
public Set<TileEntityMultiblock<T>> iteratedNodes = new HashSet<TileEntityMultiblock<T>>();
public Set<TileEntity> iteratedNodes = new HashSet<TileEntity>();
public Set<Coord4D> innerNodes = new HashSet<Coord4D>();
@ -35,7 +34,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
* Recursively loops through each node connected to the given TileEntity.
* @param tile - the TileEntity to loop over
*/
public void loopThrough(TileEntityMultiblock<T> tile)
public void loopThrough(TileEntity tile)
{
World worldObj = tile.getWorldObj();
@ -200,7 +199,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
if(structure.locations.contains(Coord4D.get(pointer)) && isCorrectCorner(Coord4D.get(tile), origX+xmin, origY+ymin, origZ+zmin))
{
if(isInteriorValid(structure))
if(canForm(structure))
{
structureFound = structure;
return;
@ -215,19 +214,20 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tileEntity = Coord4D.get(tile).getFromSide(side).getTileEntity(tile.getWorldObj());
Coord4D coord = Coord4D.get(tile).getFromSide(side);
TileEntity tileEntity = coord.getTileEntity(tile.getWorldObj());
if(MultiblockManager.areEqual(tileEntity, pointer))
if(isViableNode(coord.xCoord, coord.yCoord, coord.zCoord))
{
if(!iteratedNodes.contains(tileEntity))
{
loopThrough((TileEntityMultiblock<T>)tileEntity);
loopThrough(tileEntity);
}
}
}
}
public boolean isInteriorValid(T structure)
public boolean canForm(T structure)
{
return true;
}
@ -290,6 +290,14 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
{
TileEntity tile = pointer.getWorldObj().getTileEntity(x, y, z);
if(tile instanceof IStructuralMultiblock)
{
if(((IStructuralMultiblock)tile).canInterface(pointer))
{
return true;
}
}
if(MultiblockManager.areEqual(tile, pointer))
{
return true;
@ -392,13 +400,20 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
if(structureFound != null)
{
for(TileEntityMultiblock<T> tileEntity : iteratedNodes)
for(TileEntity tileEntity : iteratedNodes)
{
if(!structureFound.locations.contains(Coord4D.get(tileEntity)))
{
for(TileEntity tile : iteratedNodes)
{
((TileEntityMultiblock<T>)tile).structure = null;
if(tile instanceof TileEntityMultiblock)
{
((TileEntityMultiblock<T>)tile).structure = null;
}
else if(tile instanceof IStructuralMultiblock)
{
((IStructuralMultiblock)tile).setController(null);
}
}
return;
@ -410,11 +425,11 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
for(Coord4D obj : structureFound.locations)
{
TileEntityMultiblock<T> tileEntity = (TileEntityMultiblock<T>)obj.getTileEntity(pointer.getWorldObj());
TileEntity tileEntity = obj.getTileEntity(pointer.getWorldObj());
if(tileEntity.cachedID != null)
if(tileEntity instanceof TileEntityMultiblock && ((TileEntityMultiblock<T>)tileEntity).cachedID != null)
{
idsFound.add(tileEntity.cachedID);
idsFound.add(((TileEntityMultiblock<T>)tileEntity).cachedID);
}
}
@ -452,24 +467,55 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
onFormed();
structureFound.inventoryID = idToUse;
List<IStructuralMultiblock> structures = new ArrayList<IStructuralMultiblock>();
Coord4D toUse = null;
for(Coord4D obj : structureFound.locations)
{
TileEntityMultiblock<T> tileEntity = (TileEntityMultiblock<T>)obj.getTileEntity(pointer.getWorldObj());
TileEntity tileEntity = obj.getTileEntity(pointer.getWorldObj());
tileEntity.structure = (T)structureFound;
if(tileEntity instanceof TileEntityMultiblock)
{
((TileEntityMultiblock<T>)tileEntity).structure = structureFound;
if(toUse == null)
{
toUse = obj.clone();
}
}
else if(tileEntity instanceof IStructuralMultiblock)
{
structures.add((IStructuralMultiblock)tileEntity);
}
}
//Remove all structural multiblocks from locations, set controllers
for(IStructuralMultiblock node : structures)
{
node.setController(toUse);
structureFound.locations.remove(Coord4D.get((TileEntity)node));
}
}
else {
for(TileEntityMultiblock<T> tileEntity : iteratedNodes)
for(TileEntity tile : iteratedNodes)
{
if(tileEntity.structure != null && !tileEntity.structure.destroyed)
if(tile instanceof TileEntityMultiblock)
{
onStructureDestroyed(tileEntity.structure);
tileEntity.structure.destroyed = true;
TileEntityMultiblock<T> tileEntity = (TileEntityMultiblock<T>)tile;
if(tileEntity.structure != null && !tileEntity.structure.destroyed)
{
onStructureDestroyed(tileEntity.structure);
tileEntity.structure.destroyed = true;
}
tileEntity.structure = null;
}
else if(tile instanceof IStructuralMultiblock)
{
((IStructuralMultiblock)tile).setController(null);
}
tileEntity.structure = null;
}
}
}

View file

@ -10,6 +10,7 @@ import mekanism.api.Coord4D;
import mekanism.api.Range4D;
import mekanism.common.Mekanism;
import mekanism.common.base.IFluidContainerManager;
import mekanism.common.block.BlockBasic;
import mekanism.common.content.tank.SynchronizedTankData;
import mekanism.common.content.tank.SynchronizedTankData.ValveData;
import mekanism.common.content.tank.TankCache;
@ -18,6 +19,7 @@ import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.FluidContainerUtils;
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
@ -280,6 +282,27 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
}
}
@Override
public boolean onActivate(EntityPlayer player)
{
if(!player.isSneaking() && structure != null)
{
if(!BlockBasic.manageInventory(player, this))
{
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
player.openGui(Mekanism.instance, 18, worldObj, xCoord, yCoord, zCoord);
}
else {
player.inventory.markDirty();
sendPacketToRenderer();
}
return true;
}
return false;
}
@Override
protected SynchronizedTankData getNewStructure()
{

View file

@ -1,6 +1,11 @@
package mekanism.common.tile;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import mekanism.api.Coord4D;
import mekanism.api.Range4D;
import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.common.Mekanism;
import mekanism.common.content.matrix.MatrixCache;
@ -8,13 +13,13 @@ import mekanism.common.content.matrix.MatrixUpdateProtocol;
import mekanism.common.content.matrix.SynchronizedMatrixData;
import mekanism.common.integration.IComputerIntegration;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
public class TileEntityInductionCasing extends TileEntityMultiblock<SynchronizedMatrixData> implements IStrictEnergyStorage, IComputerIntegration
{
public int clientCells;
@ -52,6 +57,20 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
}
}
@Override
public boolean onActivate(EntityPlayer player)
{
if(!player.isSneaking() && structure != null)
{
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
player.openGui(Mekanism.instance, 49, worldObj, xCoord, yCoord, zCoord);
return true;
}
return false;
}
@Override
public ArrayList getNetworkedData(ArrayList data)
{

View file

@ -8,6 +8,7 @@ import mekanism.api.Coord4D;
import mekanism.api.Range4D;
import mekanism.common.Mekanism;
import mekanism.common.multiblock.IMultiblock;
import mekanism.common.multiblock.IStructuralMultiblock;
import mekanism.common.multiblock.MultiblockCache;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.multiblock.SynchronizedData;
@ -133,6 +134,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
}
}
@Override
public void update()
{
if(!worldObj.isRemote && (structure == null || !getSynchronizedData().didTick))
@ -273,6 +275,12 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
}
}
@Override
public boolean onActivate(EntityPlayer player)
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()

View file

@ -758,10 +758,7 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora
}
@Override
public void setActive(boolean active)
{
}
public void setActive(boolean active) {}
@Override
public boolean renderUpdate()

View file

@ -0,0 +1,111 @@
package mekanism.common.tile;
import java.util.HashSet;
import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.common.multiblock.IMultiblock;
import mekanism.common.multiblock.IStructuralMultiblock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityStructuralGlass extends TileEntity implements IStructuralMultiblock
{
public Coord4D master;
@Override
public boolean onActivate(EntityPlayer player)
{
if(master != null)
{
if(master.getTileEntity(worldObj) instanceof IMultiblock)
{
return ((IMultiblock)master.getTileEntity(worldObj)).onActivate(player);
}
else {
master = null;
}
}
return false;
}
@Override
public void update()
{
if(master != null)
{
if(master.getTileEntity(worldObj) instanceof IMultiblock)
{
((IMultiblock)master.getTileEntity(worldObj)).update();
}
else {
master = null;
}
}
else {
IMultiblock multiblock = new ControllerFinder().find();
if(multiblock != null)
{
multiblock.update();
}
}
}
@Override
public boolean canInterface(TileEntity controller)
{
return true;
}
@Override
public void setController(Coord4D coord)
{
master = coord;
}
public class ControllerFinder
{
public IMultiblock found;
public Set<Coord4D> iterated = new HashSet<Coord4D>();
public void loop(Coord4D pos)
{
if(iterated.size() > 512 || found != null)
{
return;
}
iterated.add(pos);
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
Coord4D coord = pos.getFromSide(side);
TileEntity tile = coord.getTileEntity(worldObj);
if(!iterated.contains(coord))
{
if(tile instanceof IMultiblock)
{
found = (IMultiblock)coord.getTileEntity(worldObj);
return;
}
else if(tile instanceof IStructuralMultiblock)
{
loop(coord);
}
}
}
}
public IMultiblock find()
{
loop(Coord4D.get(TileEntityStructuralGlass.this));
return found;
}
}
}

View file

@ -2,7 +2,10 @@ package mekanism.generators.common;
import mekanism.common.item.ItemMekanism;
import mekanism.generators.common.item.ItemHohlraum;
import mekanism.generators.common.tile.turbine.TileEntityTurbineRod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;
@ -11,7 +14,13 @@ public class GeneratorsItems
{
public static final Item SolarPanel = new ItemMekanism().setUnlocalizedName("SolarPanel");
public static final ItemHohlraum Hohlraum = (ItemHohlraum)new ItemHohlraum().setUnlocalizedName("Hohlraum");
public static final Item TurbineBlade = new ItemMekanism().setUnlocalizedName("TurbineBlade");
public static final Item TurbineBlade = new ItemMekanism() {
@Override
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player)
{
return world.getTileEntity(x, y, z) instanceof TileEntityTurbineRod;
}
}.setUnlocalizedName("TurbineBlade");
public static void register()
{

View file

@ -1,5 +1,32 @@
package mekanism.generators.common;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import mekanism.api.MekanismConfig.general;
import mekanism.api.MekanismConfig.generators;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.common.FuelHandler;
import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks;
import mekanism.common.MekanismItems;
import mekanism.common.Tier.BaseTier;
import mekanism.common.Version;
import mekanism.common.base.IModule;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.ShapedMekanismRecipe;
import mekanism.common.util.MekanismUtils;
import mekanism.generators.common.content.turbine.SynchronizedTurbineData;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.oredict.OreDictionary;
import buildcraft.api.fuels.BuildcraftFuelRegistry;
import buildcraft.api.fuels.IFuel;
import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
@ -13,26 +40,6 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import io.netty.buffer.ByteBuf;
import mekanism.api.MekanismConfig.general;
import mekanism.api.MekanismConfig.generators;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.common.*;
import mekanism.common.Tier.BaseTier;
import mekanism.common.base.IModule;
import mekanism.common.recipe.ShapedMekanismRecipe;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.util.MekanismUtils;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.oredict.OreDictionary;
import java.io.IOException;
@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "9.0.0", dependencies = "required-after:Mekanism", guiFactory = "mekanism.generators.client.gui.GeneratorsGuiFactory")
public class MekanismGenerators implements IModule
@ -48,6 +55,8 @@ public class MekanismGenerators implements IModule
/** MekanismGenerators version number */
public static Version versionNumber = new Version(9, 0, 0);
public static MultiblockManager<SynchronizedTurbineData> turbineManager = new MultiblockManager<SynchronizedTurbineData>("industrialTurbine");
@EventHandler
public void preInit(FMLPreInitializationEvent event)

View file

@ -1,4 +1,4 @@
package mekanism.common.content.turbine;
package mekanism.generators.common.content.turbine;
import mekanism.common.multiblock.SynchronizedData;

View file

@ -1,13 +1,12 @@
package mekanism.common.content.turbine;
import mekanism.common.multiblock.MultiblockCache;
package mekanism.generators.common.content.turbine;
import net.minecraft.nbt.NBTTagCompound;
import mekanism.common.multiblock.MultiblockCache;
public class TurbineCache extends MultiblockCache<SynchronizedTurbineData>
{
@Override
public void apply(SynchronizedTurbineData data)
public void apply(SynchronizedTurbineData data)
{
}
@ -19,7 +18,7 @@ public class TurbineCache extends MultiblockCache<SynchronizedTurbineData>
}
@Override
public void load(NBTTagCompound nbtTags)
public void load(NBTTagCompound nbtTags)
{
}

View file

@ -0,0 +1,48 @@
package mekanism.generators.common.content.turbine;
import java.util.List;
import mekanism.common.multiblock.MultiblockCache;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.multiblock.UpdateProtocol;
import mekanism.generators.common.MekanismGenerators;
import mekanism.generators.common.tile.turbine.TileEntityTurbineCasing;
import net.minecraft.item.ItemStack;
public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineData>
{
public TurbineUpdateProtocol(TileEntityTurbineCasing tileEntity)
{
super(tileEntity);
}
@Override
protected boolean isValidFrame(int x, int y, int z)
{
return false;
}
@Override
protected MultiblockCache<SynchronizedTurbineData> getNewCache()
{
return new TurbineCache();
}
@Override
protected SynchronizedTurbineData getNewStructure()
{
return new SynchronizedTurbineData();
}
@Override
protected MultiblockManager<SynchronizedTurbineData> getManager()
{
return MekanismGenerators.turbineManager;
}
@Override
protected void mergeCaches(List<ItemStack> rejectedItems, MultiblockCache<SynchronizedTurbineData> cache, MultiblockCache<SynchronizedTurbineData> merge)
{
}
}

View file

@ -65,7 +65,20 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
super(block);
metaBlock = block;
setHasSubtypes(true);
setMaxStackSize(1);
}
@Override
public int getItemStackLimit(ItemStack stack)
{
GeneratorType type = GeneratorType.getFromMetadata(stack.getItemDamage());
if(type == GeneratorType.TURBINE_ROD || type == GeneratorType.ROTATIONAL_COMPLEX)
{
return 64;
}
else {
return 1;
}
}
@Override

View file

@ -0,0 +1,47 @@
package mekanism.generators.common.tile.turbine;
import mekanism.common.multiblock.MultiblockCache;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.multiblock.UpdateProtocol;
import mekanism.common.tile.TileEntityMultiblock;
import mekanism.generators.common.MekanismGenerators;
import mekanism.generators.common.content.turbine.SynchronizedTurbineData;
import mekanism.generators.common.content.turbine.TurbineCache;
import mekanism.generators.common.content.turbine.TurbineUpdateProtocol;
public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTurbineData>
{
public TileEntityTurbineCasing()
{
this("TurbineCasing");
}
public TileEntityTurbineCasing(String name)
{
super(name);
}
@Override
protected SynchronizedTurbineData getNewStructure()
{
return new SynchronizedTurbineData();
}
@Override
public MultiblockCache<SynchronizedTurbineData> getNewCache()
{
return new TurbineCache();
}
@Override
protected UpdateProtocol<SynchronizedTurbineData> getProtocol()
{
return new TurbineUpdateProtocol(this);
}
@Override
public MultiblockManager<SynchronizedTurbineData> getManager()
{
return MekanismGenerators.turbineManager;
}
}

View file

@ -77,7 +77,7 @@ tile.BasicBlock.Bin.name=Bin
tile.BasicBlock.TeleporterFrame.name=Teleporter Frame
tile.BasicBlock.SteelCasing.name=Steel Casing
tile.BasicBlock.DynamicTank.name=Dynamic Tank
tile.BasicBlock.DynamicGlass.name=Dynamic Glass
tile.BasicBlock.StructuralGlass.name=Structural Glass
tile.BasicBlock.DynamicValve.name=Dynamic Valve
tile.BasicBlock.CopperBlock.name=Copper Block
tile.BasicBlock.TinBlock.name=Tin Block