Fixed some compile errors again, sorry :(

This commit is contained in:
Modmuss50 2015-04-17 18:24:52 +01:00
parent 8d8814bb77
commit c4dd21b39e
5 changed files with 52 additions and 17 deletions

View file

@ -8,7 +8,10 @@ public abstract class BaseMultiBlock implements IMultiBlock {
TileEntity parent;
public BaseMultiBlock(TileEntity parent) {
public BaseMultiBlock() {
}
public void setParent(TileEntity parent) {
this.parent = parent;
}

View file

@ -14,4 +14,13 @@ public class MultiBlockController extends TileEntity implements IMultiBlockContr
public IMultiBlock getMultiBlock() {
return multiBlock;
}
public void setMultiBlock(TileEntity tileEntity, BaseMultiBlock multiBlock){
this.multiBlock = multiBlock;
}
public void setParent(TileEntity tileEntity){
multiBlock.setParent(tileEntity);
}
}

View file

@ -1,26 +1,51 @@
package techreborn.event;
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
public void blockBreakEvent(net.minecraftforge.event.world.BlockEvent.BreakEvent event){
if(event.world.getTileEntity(event.x, event.y, event.z) instanceof IMultiblockComponent){
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);
// if(component.getMultiblock() != null)
// component.getMultiblock().recompute();
//TODO find all multiblock controllers fo the same type that are near this location and recompute.
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
public void blockPlaceEvent(net.minecraftforge.event.world.BlockEvent.PlaceEvent event){
if(event.world.getTileEntity(event.x, event.y, event.z) instanceof IMultiblockComponent){
@SubscribeEvent(priority =)
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);
// if(component.getMultiblock() != null)
// component.getMultiblock().recompute();
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());
}
}
}
}
}
}
}

View file

@ -8,9 +8,6 @@ import java.util.List;
public class MultiBlastfurnace extends BaseMultiBlock {
public MultiBlastfurnace(TileEntity parent) {
super(parent);
}
@Override
public String getName() {
@ -30,6 +27,6 @@ public class MultiBlastfurnace extends BaseMultiBlock {
@Override
public void recompute() {
setIsComplete(checkIfComplete());
}
}

View file

@ -4,7 +4,7 @@ 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.IMultiBlock;
import techreborn.api.multiblock.BaseMultiBlock;
import techreborn.api.multiblock.MultiBlockController;
import techreborn.init.ModBlocks;
import techreborn.util.Inventory;
@ -15,8 +15,9 @@ public class TileBlastFurnace extends MultiBlockController implements IWrenchabl
public BasicSink energy;
public Inventory inventory = new Inventory(3, "TileBlastFurnace", 64);
public TileBlastFurnace(IMultiBlock multiBlock) {
public TileBlastFurnace(BaseMultiBlock multiBlock) {
super(multiBlock);
setParent(this);
}
@Override