This was to complicated, going to make it simpler
This commit is contained in:
parent
314a9637b7
commit
bb58ae8632
12 changed files with 4 additions and 219 deletions
|
@ -6,13 +6,11 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
|||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import techreborn.achievement.TRAchievements;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.compat.CompatManager;
|
||||
import techreborn.compat.recipes.RecipeManager;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.event.MultiblockEvent;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.init.ModRecipes;
|
||||
|
@ -57,8 +55,6 @@ public class Core {
|
|||
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
|
||||
//packets
|
||||
PacketHandler.setChannels(NetworkRegistry.INSTANCE.newChannel(ModInfo.MOD_ID + "_packets", new PacketHandler()));
|
||||
//Events
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockEvent());
|
||||
//Achievements
|
||||
TRAchievements.init();
|
||||
LogHelper.info("Initialization Compleate");
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package techreborn.api.multiblock;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public abstract class BaseMultiBlock implements IMultiBlock {
|
||||
|
||||
boolean isComplete = false;
|
||||
|
||||
TileEntity parent;
|
||||
|
||||
public BaseMultiBlock() {
|
||||
}
|
||||
|
||||
public void setParent(TileEntity parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete() {
|
||||
return isComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getController() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setIsComplete(boolean isComplete) {
|
||||
this.isComplete = isComplete;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package techreborn.api.multiblock;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IMultiBlock {
|
||||
|
||||
/**
|
||||
* This is the name of the multiblock
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* This check to see if the multiblock is complete
|
||||
*/
|
||||
boolean checkIfComplete();
|
||||
|
||||
/**
|
||||
* This check to see if the multiblock is complete
|
||||
*/
|
||||
boolean isComplete();
|
||||
|
||||
/**
|
||||
* This is a list of all of the tiles that make up the multiblock
|
||||
*/
|
||||
List<TileEntity> getTiles();
|
||||
|
||||
/**
|
||||
* This is the controller for the whole multiblock structure.
|
||||
*
|
||||
* This tile will store the nbt and do the logic for the whole system. Send block actions to this block.
|
||||
*/
|
||||
TileEntity getController();
|
||||
|
||||
/**
|
||||
* Call this from the controller to allow to tile to update is completeness.
|
||||
*/
|
||||
void recompute();
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package techreborn.api.multiblock;
|
||||
|
||||
public interface IMultiBlockController {
|
||||
|
||||
IMultiBlock getMultiBlock();
|
||||
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package techreborn.api.multiblock;
|
||||
|
||||
public interface IMultiblockComponent {
|
||||
|
||||
/**
|
||||
* This gets the instance of the multiblock , allow for different meta data for different structures,
|
||||
*/
|
||||
Class getMultiblockType();
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package techreborn.api.multiblock;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class MultiBlockController extends TileEntity implements IMultiBlockController{
|
||||
|
||||
BaseMultiBlock multiBlock;
|
||||
|
||||
public MultiBlockController(BaseMultiBlock multiBlock) {
|
||||
this.multiBlock = multiBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMultiBlock getMultiBlock() {
|
||||
return multiBlock;
|
||||
}
|
||||
|
||||
public void setMultiBlock(TileEntity tileEntity, BaseMultiBlock multiBlock){
|
||||
this.multiBlock = multiBlock;
|
||||
|
||||
}
|
||||
|
||||
public void setParent(TileEntity tileEntity){
|
||||
multiBlock.setParent(tileEntity);
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.multiblock;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
|
@ -12,7 +12,6 @@ import net.minecraft.world.World;
|
|||
import techreborn.Core;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.multiblocks.MultiBlastfurnace;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
|
||||
public class BlockBlastFurnace extends BlockContainer{
|
||||
|
@ -32,7 +31,7 @@ public class BlockBlastFurnace extends BlockContainer{
|
|||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
|
||||
return new TileBlastFurnace(new MultiBlastfurnace());
|
||||
return new TileBlastFurnace();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package techreborn.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import techreborn.api.multiblock.IMultiBlockController;
|
||||
import techreborn.api.multiblock.IMultiblockComponent;
|
||||
|
||||
public class MultiblockEvent {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void blockBreakEvent(net.minecraftforge.event.world.BlockEvent.BreakEvent event) {
|
||||
if (event.world.getTileEntity(event.x, event.y, event.z) instanceof IMultiblockComponent) {
|
||||
IMultiblockComponent component = (IMultiblockComponent) event.world.getTileEntity(event.x, event.y, event.z);
|
||||
for (int x = -3; x < 3; x++) {
|
||||
for (int y = -3; y < 3; y++) {
|
||||
for (int z = -3; z < 3; z++) {
|
||||
//TODO have a quicker way of doing this, Arraylist with all controllers?
|
||||
TileEntity tile = event.world.getTileEntity(x + event.x, y + event.y, z + event.z);
|
||||
if (tile != null && tile instanceof IMultiBlockController) {
|
||||
IMultiBlockController controller = (IMultiBlockController) tile;
|
||||
controller.getMultiBlock().recompute();
|
||||
System.out.println(controller.getMultiBlock().isComplete());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void blockPlaceEvent(net.minecraftforge.event.world.BlockEvent.PlaceEvent event) {
|
||||
if (event.world.getTileEntity(event.x, event.y, event.z) instanceof IMultiblockComponent) {
|
||||
IMultiblockComponent component = (IMultiblockComponent) event.world.getTileEntity(event.x, event.y, event.z);
|
||||
for (int x = -3; x < 3; x++) {
|
||||
for (int y = -3; y < 3; y++) {
|
||||
for (int z = -3; z < 3; z++) {
|
||||
//TODO have a quicker way of doing this
|
||||
TileEntity tile = event.world.getTileEntity(x + event.x, y + event.y, z + event.z);
|
||||
if (tile != null && tile instanceof IMultiBlockController) {
|
||||
IMultiBlockController controller = (IMultiBlockController) tile;
|
||||
controller.getMultiBlock().recompute();
|
||||
System.out.println(controller.getMultiBlock().isComplete());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
package techreborn.multiblocks;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import techreborn.api.multiblock.BaseMultiBlock;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MultiBlastfurnace extends BaseMultiBlock {
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "BlastFurnaceMultiBlock";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkIfComplete() {
|
||||
return getController().getWorldObj().getBlock(getController().xCoord, getController().yCoord + 1, getController().zCoord) == ModBlocks.MachineCasing;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TileEntity> getTiles() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recompute() {
|
||||
setIsComplete(checkIfComplete());
|
||||
}
|
||||
}
|
|
@ -4,20 +4,16 @@ import ic2.api.energy.prefab.BasicSink;
|
|||
import ic2.api.tile.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.api.multiblock.BaseMultiBlock;
|
||||
import techreborn.api.multiblock.MultiBlockController;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.util.Inventory;
|
||||
|
||||
public class TileBlastFurnace extends MultiBlockController implements IWrenchable {
|
||||
public class TileBlastFurnace extends TileMachineBase implements IWrenchable {
|
||||
|
||||
public int tickTime;
|
||||
public BasicSink energy;
|
||||
public Inventory inventory = new Inventory(3, "TileBlastFurnace", 64);
|
||||
|
||||
public TileBlastFurnace(BaseMultiBlock multiBlock) {
|
||||
super(multiBlock);
|
||||
setParent(this);
|
||||
public TileBlastFurnace() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import techreborn.api.multiblock.IMultiblockComponent;
|
||||
import techreborn.multiblocks.MultiBlastfurnace;
|
||||
|
||||
public class TileMachineCasing extends TileEntity implements IMultiblockComponent {
|
||||
public class TileMachineCasing extends TileEntity {
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
|
@ -12,8 +10,4 @@ public class TileMachineCasing extends TileEntity implements IMultiblockComponen
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getMultiblockType() {
|
||||
return MultiBlastfurnace.class;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue