Initial work on the multiblock system
This commit is contained in:
parent
1f1096dd49
commit
cad9b8cc56
4 changed files with 70 additions and 0 deletions
35
src/main/java/techreborn/api/multiblock/IMultiBlock.java
Normal file
35
src/main/java/techreborn/api/multiblock/IMultiBlock.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package techreborn.api.multiblock;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IMultiBlock {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the name of the multiblock
|
||||||
|
*/
|
||||||
|
void getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This check to see if the multiblock is complete
|
||||||
|
*/
|
||||||
|
boolean checkIfComplete(int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package techreborn.api.multiblock;
|
||||||
|
|
||||||
|
public interface IMultiblockComponent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gets the multiblock type, allow for different meta data for different structures,
|
||||||
|
*/
|
||||||
|
IMultiBlock getMultiblock(int meta);
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api.multiblock;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.API;
|
23
src/main/java/techreborn/event/MultiblockEvent.java
Normal file
23
src/main/java/techreborn/event/MultiblockEvent.java
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package techreborn.event;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import techreborn.api.multiblock.IMultiblockComponent;
|
||||||
|
|
||||||
|
public class MultiblockEvent {
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void blockBreakEvent(net.minecraftforge.event.world.BlockEvent.BreakEvent event){
|
||||||
|
if(event.block instanceof IMultiblockComponent){
|
||||||
|
IMultiblockComponent component = (IMultiblockComponent) event.block;
|
||||||
|
component.getMultiblock(event.world.getBlockMetadata(event.x, event.y, event.z)).recompute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void blockPlaceEvent(net.minecraftforge.event.world.BlockEvent.PlaceEvent event){
|
||||||
|
if(event.block instanceof IMultiblockComponent){
|
||||||
|
IMultiblockComponent component = (IMultiblockComponent) event.block;
|
||||||
|
component.getMultiblock(event.world.getBlockMetadata(event.x, event.y, event.z)).recompute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue