use of gregtech.api.metatileentity.multiblock.MultiblockControllerBase in project GregTech by GregTechCEu.
the class MetaTileEntityMaintenanceHatch method update.
@Override
public void update() {
super.update();
if (!getWorld().isRemote && getOffsetTimer() % 20 == 0) {
MultiblockControllerBase controller = getController();
if (controller instanceof IMaintenance) {
if (((IMaintenance) controller).hasMaintenanceProblems()) {
if (consumeDuctTape(this.itemInventory, 0)) {
fixAllMaintenanceProblems();
setTaped(true);
}
}
}
}
}
use of gregtech.api.metatileentity.multiblock.MultiblockControllerBase in project GregTech by GregTechCEu.
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 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 GregTechCEu.
the class JEIOptional method getWorldSceneRenderer.
@Optional.Method(modid = "jei")
public static WorldSceneRenderer getWorldSceneRenderer(MultiblockControllerBase controllerBase) {
IRecipeRegistry rr = GTJeiPlugin.jeiRuntime.getRecipeRegistry();
IFocus<ItemStack> focus = rr.createFocus(IFocus.Mode.INPUT, controllerBase.getStackForm());
return rr.getRecipeCategories(focus).stream().map(c -> (IRecipeCategory<IRecipeWrapper>) c).map(c -> rr.getRecipeWrappers(c, focus)).flatMap(List::stream).filter(MultiblockInfoRecipeWrapper.class::isInstance).findFirst().map(MultiblockInfoRecipeWrapper.class::cast).map(MultiblockInfoRecipeWrapper::getCurrentRenderer).orElse(null);
}
use of gregtech.api.metatileentity.multiblock.MultiblockControllerBase in project GregTech by GregTechCEu.
the class MultiblockInfoRecipeWrapper method initializePattern.
private MBPattern initializePattern(MultiblockShapeInfo shapeInfo, Set<ItemStackKey> blockDrops) {
Map<BlockPos, BlockInfo> blockMap = new HashMap<>();
MultiblockControllerBase controllerBase = null;
BlockInfo[][][] blocks = shapeInfo.getBlocks();
for (int x = 0; x < blocks.length; x++) {
BlockInfo[][] aisle = blocks[x];
for (int y = 0; y < aisle.length; y++) {
BlockInfo[] column = aisle[y];
for (int z = 0; z < column.length; z++) {
if (column[z].getTileEntity() instanceof MetaTileEntityHolder && ((MetaTileEntityHolder) column[z].getTileEntity()).getMetaTileEntity() instanceof MultiblockControllerBase) {
controllerBase = (MultiblockControllerBase) ((MetaTileEntityHolder) column[z].getTileEntity()).getMetaTileEntity();
}
blockMap.put(new BlockPos(x, y, z), column[z]);
}
}
}
TrackedDummyWorld world = new TrackedDummyWorld();
ImmediateWorldSceneRenderer worldSceneRenderer = new ImmediateWorldSceneRenderer(world);
worldSceneRenderer.setClearColor(0xC6C6C6);
world.addBlocks(blockMap);
Vector3f size = world.getSize();
Vector3f minPos = world.getMinPos();
center = new Vector3f(minPos.x + size.x / 2, minPos.y + size.y / 2, minPos.z + size.z / 2);
worldSceneRenderer.addRenderedBlocks(world.renderedBlocks, null);
worldSceneRenderer.setOnLookingAt(ray -> {
});
worldSceneRenderer.setAfterWorldRender(renderer -> {
BlockPos look = worldSceneRenderer.getLastTraceResult() == null ? null : worldSceneRenderer.getLastTraceResult().getBlockPos();
if (look != null && look.equals(selected)) {
renderBlockOverLay(selected, 200, 75, 75);
return;
}
renderBlockOverLay(look, 150, 150, 150);
renderBlockOverLay(selected, 255, 0, 0);
});
world.updateEntities();
world.setRenderFilter(pos -> worldSceneRenderer.renderedBlocksMap.keySet().stream().anyMatch(c -> c.contains(pos)));
List<ItemStack> parts = gatherBlockDrops(worldSceneRenderer.world, blockMap, blockDrops).values().stream().sorted((one, two) -> {
if (one.isController)
return -1;
if (two.isController)
return +1;
if (one.isTile && !two.isTile)
return -1;
if (two.isTile && !one.isTile)
return +1;
if (one.blockId != two.blockId)
return two.blockId - one.blockId;
return two.amount - one.amount;
}).map(PartInfo::getItemStack).collect(Collectors.toList());
Map<BlockPos, TraceabilityPredicate> predicateMap = new HashMap<>();
if (controllerBase != null) {
controllerBase.structurePattern.cache.forEach((pos, blockInfo) -> predicateMap.put(BlockPos.fromLong(pos), (TraceabilityPredicate) blockInfo.getInfo()));
}
return new MBPattern(worldSceneRenderer, parts, predicateMap);
}
Aggregations