use of gregtech.api.metatileentity.multiblock.MultiblockControllerBase in project GregTech by GregTechCE.
the class MetaTileEntityMultiblockPart method onRemoval.
@Override
public void onRemoval() {
super.onRemoval();
MultiblockControllerBase controller = getController();
if (!getWorld().isRemote && controller != null) {
controller.invalidateStructure();
}
}
use of gregtech.api.metatileentity.multiblock.MultiblockControllerBase in project GregTech by GregTechCE.
the class MetaTileEntityMultiblockPart method writeInitialSyncData.
@Override
public void writeInitialSyncData(PacketBuffer buf) {
super.writeInitialSyncData(buf);
MultiblockControllerBase controller = getController();
buf.writeBoolean(controller != null);
if (controller != null) {
buf.writeBlockPos(controller.getPos());
}
}
use of gregtech.api.metatileentity.multiblock.MultiblockControllerBase in project GregTech by GregTechCEu.
the class IParallelableRecipeLogicTest method initEBF.
private MetaTileEntityElectricBlastFurnace initEBF(int id) {
World world = DummyWorld.INSTANCE;
mbt = MetaTileEntities.registerMetaTileEntity(id, new MetaTileEntityElectricBlastFurnace(// super function calls the world, which equal null in test
new ResourceLocation(GTValues.MODID, "electric_blast_furnace")) {
@Override
public boolean canBeDistinct() {
return false;
}
@Override
public void reinitializeStructurePattern() {
}
// function checks for the temperature of the recipe against the coils
@Override
public boolean checkRecipe(@Nonnull Recipe recipe, boolean consumeIfSuccess) {
return true;
}
// ignore maintenance problems
@Override
public boolean hasMaintenanceMechanics() {
return false;
}
});
try {
Field field = MetaTileEntityElectricBlastFurnace.class.getSuperclass().getDeclaredField("recipeMapWorkable");
field.setAccessible(true);
Object recipeMapWorkableField = field.get(mbt);
Method setParallelLimitMethod = recipeMapWorkableField.getClass().getSuperclass().getSuperclass().getDeclaredMethod("setParallelLimit", int.class);
setParallelLimitMethod.setAccessible(true);
setParallelLimitMethod.invoke(recipeMapWorkableField, 4);
} catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
}
// isValid() check in the dirtying logic requires both a metatileentity and a holder
try {
Field field = MetaTileEntity.class.getDeclaredField("holder");
field.setAccessible(true);
field.set(mbt, new MetaTileEntityHolder());
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
try {
Field field = MetaTileEntityHolder.class.getDeclaredField("metaTileEntity");
field.setAccessible(true);
field.set(mbt.getHolder(), mbt);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
mbt.getHolder().setWorld(world);
// Controller and isAttachedToMultiBlock need the world so we fake it here.
importItemBus = new MetaTileEntityItemBus(gregtechId("item_bus.export.lv"), 1, false) {
@Override
public boolean isAttachedToMultiBlock() {
return true;
}
@Override
public MultiblockControllerBase getController() {
return mbt;
}
};
exportItemBus = new MetaTileEntityItemBus(gregtechId("item_bus.export.lv"), 1, true) {
@Override
public boolean isAttachedToMultiBlock() {
return true;
}
@Override
public MultiblockControllerBase getController() {
return mbt;
}
};
importFluidBus = new MetaTileEntityFluidHatch(gregtechId("fluid_hatch.import.lv"), 1, false) {
@Override
public boolean isAttachedToMultiBlock() {
return true;
}
@Override
public MultiblockControllerBase getController() {
return mbt;
}
};
exportFluidBus = new MetaTileEntityFluidHatch(gregtechId("fluid_hatch.export.lv"), 1, true) {
@Override
public boolean isAttachedToMultiBlock() {
return true;
}
@Override
public MultiblockControllerBase getController() {
return mbt;
}
};
// Controller is a private field but we need that information
try {
Field field = MetaTileEntityMultiblockPart.class.getDeclaredField("controllerTile");
field.setAccessible(true);
field.set(importItemBus, mbt);
field.set(exportItemBus, mbt);
field.set(importFluidBus, mbt);
field.set(exportFluidBus, mbt);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
return (MetaTileEntityElectricBlastFurnace) mbt;
}
use of gregtech.api.metatileentity.multiblock.MultiblockControllerBase in project GregTech by GregTechCEu.
the class CoverDigitalInterface method getItemCapability.
public IItemHandler getItemCapability() {
TileEntity te = getCoveredTE();
IItemHandler capability = te == null ? null : te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, getCoveredFacing());
if (capability == null && this.coverHolder instanceof MultiblockControllerBase) {
List<IItemHandlerModifiable> input = ((MultiblockControllerBase) this.coverHolder).getAbilities(MultiblockAbility.IMPORT_ITEMS);
List<IItemHandlerModifiable> output = ((MultiblockControllerBase) this.coverHolder).getAbilities(MultiblockAbility.EXPORT_ITEMS);
List<IItemHandlerModifiable> list = new ArrayList<>();
if (input.size() > 0) {
list.addAll(input);
}
if (output.size() > 0) {
list.addAll(output);
}
capability = new ItemHandlerList(list);
}
return capability;
}
use of gregtech.api.metatileentity.multiblock.MultiblockControllerBase in project GregTech by GregTechCEu.
the class MetaTileEntityMonitorScreen method onRightClick.
@Override
public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing facing, CuboidRayTraceResult hitResult) {
if (!(!playerIn.isSneaking() && playerIn.getHeldItemMainhand().hasCapability(GregtechCapabilities.CAPABILITY_SCREWDRIVER, null)) && !MetaTileEntities.MONITOR_SCREEN.getStackForm().isItemEqual(playerIn.getHeldItemMainhand())) {
if (playerIn.world.getTotalWorldTime() - lastClickTime < 2 && playerIn.getPersistentID().equals(lastClickUUID)) {
return true;
}
lastClickTime = playerIn.world.getTotalWorldTime();
lastClickUUID = playerIn.getPersistentID();
MultiblockControllerBase controller = this.getController();
if (controller instanceof MetaTileEntityCentralMonitor && ((MetaTileEntityCentralMonitor) controller).isActive() && controller.getFrontFacing() == facing) {
return handleHitResultWithScale(playerIn, hand, facing, true, hitResult);
}
}
return false;
}
Aggregations