diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/blockentity/PipeBlockEntity.java b/common/src/main/java/com/gregtechceu/gtceu/api/blockentity/PipeBlockEntity.java index 4eb77d7e03..031e5ba217 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/blockentity/PipeBlockEntity.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/blockentity/PipeBlockEntity.java @@ -68,7 +68,7 @@ public abstract class PipeBlockEntity & IPipeTyp @Persisted(key = "cover") protected final PipeCoverContainer coverContainer; - @Setter + @Getter @Setter @DescSynced @Persisted @RequireRerender @@ -133,6 +133,17 @@ public void clearRemoved() { coverContainer.onLoad(); } + @Override + public int getNumConnections() { + int count = 0; + int connections = getConnections(); + while (connections > 0) { + count++; + connections = connections & (connections - 1); + } + return count; + } + @Nullable public TickableSubscription subscribeServerTick(Runnable runnable) { if (!isRemote()) { diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/capability/GTCapabilityHelper.java b/common/src/main/java/com/gregtechceu/gtceu/api/capability/GTCapabilityHelper.java index 4af3763065..2d1e74bf77 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/capability/GTCapabilityHelper.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/capability/GTCapabilityHelper.java @@ -81,4 +81,10 @@ public static ICleanroomReceiver getCleanroomReceiver(Level level, BlockPos pos, public static IMaintenanceMachine getMaintenanceMachine(Level level, BlockPos pos, @Nullable Direction side) { throw new AssertionError(); } + + @ExpectPlatform + @Nullable + public static ILaserContainer getLaser(Level level, BlockPos pos, @Nullable Direction side) { + throw new AssertionError(); + } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/capability/ILaserContainer.java b/common/src/main/java/com/gregtechceu/gtceu/api/capability/ILaserContainer.java new file mode 100644 index 0000000000..b795b26302 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/api/capability/ILaserContainer.java @@ -0,0 +1,7 @@ +package com.gregtechceu.gtceu.api.capability; + +/** + * It is its own separate interface to make piping work easier + */ +public interface ILaserContainer extends IEnergyContainer { +} \ No newline at end of file diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/BlockStateRecipeCapability.java b/common/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/BlockStateRecipeCapability.java index 5da66d7b83..ac44d62bf8 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/BlockStateRecipeCapability.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/BlockStateRecipeCapability.java @@ -10,4 +10,9 @@ public class BlockStateRecipeCapability extends RecipeCapability { protected BlockStateRecipeCapability() { super("block_state", 0xFFABABAB, SerializerBlockState.INSTANCE); } + + @Override + public BlockState copyInner(BlockState content) { + return content; + } } \ No newline at end of file diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/item/LaserPipeBlockItem.java b/common/src/main/java/com/gregtechceu/gtceu/api/item/LaserPipeBlockItem.java new file mode 100644 index 0000000000..c427e84512 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/api/item/LaserPipeBlockItem.java @@ -0,0 +1,40 @@ +package com.gregtechceu.gtceu.api.item; + +import com.gregtechceu.gtceu.api.block.PipeBlock; +import com.gregtechceu.gtceu.common.block.LaserPipeBlock; +import com.lowdragmc.lowdraglib.client.renderer.IItemRendererProvider; +import com.lowdragmc.lowdraglib.client.renderer.IRenderer; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.Nullable; + +public class LaserPipeBlockItem extends PipeBlockItem implements IItemRendererProvider { + + public LaserPipeBlockItem(PipeBlock block, Properties properties) { + super(block, properties); + } + + @Override + public LaserPipeBlock getBlock() { + return (LaserPipeBlock) super.getBlock(); + } + + @Environment(EnvType.CLIENT) + public static ItemColor tintColor() { + return (itemStack, index) -> { + if (itemStack.getItem() instanceof LaserPipeBlockItem materialBlockItem) { + return materialBlockItem.getBlock().tinted(materialBlockItem.getBlock().defaultBlockState(), null, null, index); + } + return -1; + }; + } + + @Nullable + @Override + @Environment(EnvType.CLIENT) + public IRenderer getRenderer(ItemStack stack) { + return getBlock().getRenderer(getBlock().defaultBlockState()); + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/PartAbility.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/PartAbility.java index ce7a51d36c..e8521fc009 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/PartAbility.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/PartAbility.java @@ -34,6 +34,8 @@ public class PartAbility { public static final PartAbility TANK_VALVE = new PartAbility("tank_valve"); public static final PartAbility PASSTHROUGH_HATCH = new PartAbility("passthrough_hatch"); public static final PartAbility PARALLEL_HATCH = new PartAbility("parallel_hatch"); + public static final PartAbility INPUT_LASER = new PartAbility("input_laser"); + public static final PartAbility OUTPUT_LASER = new PartAbility("output_laser"); /** * tier -> available blocks diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamEnergyRecipeHandler.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamEnergyRecipeHandler.java index 9aafb5bf12..64ae8ee251 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamEnergyRecipeHandler.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamEnergyRecipeHandler.java @@ -7,6 +7,7 @@ import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank; import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient; +import com.gregtechceu.gtceu.common.data.GTMaterials; import com.gregtechceu.gtceu.data.recipe.CustomTags; import com.lowdragmc.lowdraglib.side.fluid.FluidStack; import org.jetbrains.annotations.Nullable; @@ -35,7 +36,7 @@ public List handleRecipeInner(IO io, GTRecipe recipe, List left, @Nu long sum = left.stream().reduce(0L, Long::sum); long realSum = (long) Math.ceil(sum * conversionRate); if (realSum > 0) { - var steam = FluidIngredient.of(CustomTags.STEAM, realSum); + var steam = io == IO.IN ? FluidIngredient.of(CustomTags.STEAM, realSum) : FluidIngredient.of(GTMaterials.Steam.getFluid(realSum)); var list = new ArrayList(); list.add(steam); var leftSteam = steamTank.handleRecipeInner(io, recipe, list, slotName, simulate); diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamMachine.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamMachine.java index e7437c00e2..b2ff43e991 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamMachine.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamMachine.java @@ -5,6 +5,7 @@ import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank; import com.gregtechceu.gtceu.api.machine.feature.ITieredMachine; import com.gregtechceu.gtceu.common.data.GTMaterials; +import com.gregtechceu.gtceu.data.recipe.CustomTags; import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted; import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; import lombok.Getter; @@ -31,7 +32,7 @@ public SteamMachine(IMachineBlockEntity holder, boolean isHighPressure, Object.. super(holder); this.isHighPressure = isHighPressure; this.steamTank = createSteamTank(args); - this.steamTank.setFilter(fluid -> GTMaterials.Steam.getFluid() == fluid.getFluid()); + this.steamTank.setFilter(fluidStack -> fluidStack.getFluid().is(CustomTags.STEAM)); } ////////////////////////////////////// diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableEnergyContainer.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableEnergyContainer.java index 62f325794a..70e8bbb61b 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableEnergyContainer.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableEnergyContainer.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.List; -import java.util.Set; import java.util.function.Predicate; public class NotifiableEnergyContainer extends NotifiableRecipeHandlerTrait implements IEnergyContainer { diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableLaserContainer.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableLaserContainer.java new file mode 100644 index 0000000000..c56c2eb700 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableLaserContainer.java @@ -0,0 +1,52 @@ +package com.gregtechceu.gtceu.api.machine.trait; + +import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; +import com.gregtechceu.gtceu.api.capability.ILaserContainer; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.entity.BlockEntity; + +public class NotifiableLaserContainer extends NotifiableEnergyContainer implements ILaserContainer { + + public static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(NotifiableEnergyContainer.class, NotifiableRecipeHandlerTrait.MANAGED_FIELD_HOLDER); + + public NotifiableLaserContainer(MetaMachine machine, long maxCapacity, long maxInputVoltage, long maxInputAmperage, long maxOutputVoltage, long maxOutputAmperage) { + super(machine, maxCapacity, maxInputVoltage, maxInputAmperage, maxOutputVoltage, maxOutputAmperage); + } + + public static NotifiableLaserContainer emitterContainer(MetaMachine machine, long maxCapacity, long maxOutputVoltage, long maxOutputAmperage) { + return new NotifiableLaserContainer(machine, maxCapacity, 0L, 0L, maxOutputVoltage, maxOutputAmperage); + } + + public static NotifiableLaserContainer receiverContainer(MetaMachine machine, long maxCapacity, long maxInputVoltage, long maxInputAmperage) { + return new NotifiableLaserContainer(machine, maxCapacity, maxInputVoltage, maxInputAmperage, 0L, 0L); + } + + @Override + public void serverTick() { + amps = 0; + if (getMachine().getLevel().isClientSide) + return; + if (getEnergyStored() < getOutputVoltage() || getOutputVoltage() <= 0 || getOutputAmperage() <= 0) + return; + long outputVoltage = getOutputVoltage(); + long outputAmperes = Math.min(getEnergyStored() / outputVoltage, getOutputAmperage()); + if (outputAmperes == 0) return; + long amperesUsed = 0; + for (Direction side : Direction.values()) { + if (!outputsEnergy(side)) continue; + BlockEntity tileEntity = getMachine().getLevel().getBlockEntity(getMachine().getPos().relative(side)); + Direction oppositeSide = side.getOpposite(); + ILaserContainer laserContainer = GTCapabilityHelper.getLaser(getMachine().getLevel(), getMachine().getPos().relative(side), oppositeSide); + if (tileEntity != null && laserContainer != null) { + if (laserContainer == null || !laserContainer.inputsEnergy(oppositeSide)) continue; + amperesUsed += laserContainer.acceptEnergyFromNetwork(oppositeSide, outputVoltage, outputAmperes - amperesUsed); + if (amperesUsed == outputAmperes) break; + } + } + if (amperesUsed > 0) { + setEnergyStored(getEnergyStored() - amperesUsed * outputVoltage); + } + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/misc/LaserContainerList.java b/common/src/main/java/com/gregtechceu/gtceu/api/misc/LaserContainerList.java new file mode 100644 index 0000000000..9aae74beb7 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/api/misc/LaserContainerList.java @@ -0,0 +1,98 @@ +package com.gregtechceu.gtceu.api.misc; + +import com.gregtechceu.gtceu.api.capability.IEnergyContainer; +import com.gregtechceu.gtceu.api.capability.ILaserContainer; +import net.minecraft.core.Direction; + +import java.util.List; + +public class LaserContainerList implements ILaserContainer { + + private final List energyContainerList; + + public LaserContainerList(List energyContainerList) { + this.energyContainerList = energyContainerList; + } + + @Override + public long acceptEnergyFromNetwork(Direction side, long voltage, long amperage) { + long amperesUsed = 0L; + List energyContainerList = this.energyContainerList; + for (ILaserContainer iEnergyContainer : energyContainerList) { + amperesUsed += iEnergyContainer.acceptEnergyFromNetwork(null, voltage, amperage); + if (amperage == amperesUsed) { + return amperesUsed; + } + } + return amperesUsed; + } + + @Override + public long changeEnergy(long energyToAdd) { + long energyAdded = 0L; + List energyContainerList = this.energyContainerList; + for (ILaserContainer iEnergyContainer : energyContainerList) { + energyAdded += iEnergyContainer.changeEnergy(energyToAdd - energyAdded); + if (energyAdded == energyToAdd) { + return energyAdded; + } + } + return energyAdded; + } + + @Override + public long getEnergyStored() { + long energyStored = 0L; + for (ILaserContainer iEnergyContainer : energyContainerList) { + energyStored += iEnergyContainer.getEnergyStored(); + } + return energyStored; + } + + @Override + public long getEnergyCapacity() { + long energyCapacity = 0L; + for (ILaserContainer iEnergyContainer : energyContainerList) { + energyCapacity += iEnergyContainer.getEnergyCapacity(); + } + return energyCapacity; + } + + @Override + public long getInputAmperage() { + return 1L; + } + + @Override + public long getOutputAmperage() { + return 1L; + } + + @Override + public long getInputVoltage() { + long inputVoltage = 0L; + for (ILaserContainer container : energyContainerList) { + inputVoltage += container.getInputVoltage() * container.getInputAmperage(); + } + return inputVoltage; + } + + @Override + public long getOutputVoltage() { + long outputVoltage = 0L; + for (ILaserContainer container : energyContainerList) { + outputVoltage += container.getOutputVoltage() * container.getOutputAmperage(); + } + return outputVoltage; + } + + @Override + public boolean inputsEnergy(Direction side) { + return true; + } + + @Override + public boolean outputsEnergy(Direction side) { + return true; + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java b/common/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java index 1f725a0325..d050671abd 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java @@ -38,6 +38,10 @@ public interface IPipeNode & IPipeType null).getFirst(); + return BlockState.CODEC.parse(JsonOps.INSTANCE, json).getOrThrow(false, GTCEu.LOGGER::error); } @Override diff --git a/common/src/main/java/com/gregtechceu/gtceu/client/TooltipHelper.java b/common/src/main/java/com/gregtechceu/gtceu/client/TooltipHelper.java index 3832cfbf23..2c696eeb29 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/client/TooltipHelper.java +++ b/common/src/main/java/com/gregtechceu/gtceu/client/TooltipHelper.java @@ -77,6 +77,10 @@ public void updateIndex() { } } + public ChatFormatting getCurrent() { + return codes[index]; + } + @Override public String toString() { return codes[index].toString(); diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/block/LaserPipeBlock.java b/common/src/main/java/com/gregtechceu/gtceu/common/block/LaserPipeBlock.java new file mode 100644 index 0000000000..b08a21921c --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/block/LaserPipeBlock.java @@ -0,0 +1,91 @@ +package com.gregtechceu.gtceu.common.block; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.block.PipeBlock; +import com.gregtechceu.gtceu.api.blockentity.PipeBlockEntity; +import com.gregtechceu.gtceu.client.model.PipeModel; +import com.gregtechceu.gtceu.client.renderer.block.PipeBlockRenderer; +import com.gregtechceu.gtceu.common.data.GTBlockEntities; +import com.gregtechceu.gtceu.common.pipelike.laser.LaserPipeNet; +import com.gregtechceu.gtceu.common.pipelike.laser.LaserPipeProperties; +import com.gregtechceu.gtceu.common.pipelike.laser.LaserPipeType; +import com.gregtechceu.gtceu.common.pipelike.laser.LevelLaserPipeNet; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.client.color.block.BlockColor; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import org.jetbrains.annotations.Nullable; + +@MethodsReturnNonnullByDefault +public class LaserPipeBlock extends PipeBlock { + + public final DyeColor color; + public final PipeBlockRenderer renderer; + public final PipeModel model; + + public LaserPipeBlock(Properties properties, DyeColor color) { + super(properties, LaserPipeType.NORMAL); + this.color = color; + this.model = new PipeModel(LaserPipeType.NORMAL.getThickness(), () -> GTCEu.id("block/pipe/pipe_laser_side"), () -> GTCEu.id("block/pipe/pipe_laser_in")); + this.renderer = new PipeBlockRenderer(this.model); + } + + @Environment(EnvType.CLIENT) + public static BlockColor tintedColor() { + return (blockState, level, blockPos, index) -> { + if (blockState.getBlock() instanceof LaserPipeBlock block) { + if (blockPos != null && level != null && level.getBlockEntity(blockPos) instanceof PipeBlockEntity pipe && pipe.isPainted()) { + return pipe.getRealColor(); + } + return block.tinted(blockState, level, blockPos, index); + } + return -1; + }; + } + + public int tinted(BlockState blockState, @Nullable BlockAndTintGetter blockAndTintGetter, @Nullable BlockPos blockPos, int index) { + return color.getTextColor(); + } + + @Override + public LevelLaserPipeNet getWorldPipeNet(ServerLevel world) { + return LevelLaserPipeNet.getOrCreate(world); + } + + @Override + public BlockEntityType> getBlockEntityType() { + return GTBlockEntities.LASER_PIPE.get(); + } + + @Override + public LaserPipeNet.LaserData createRawData(BlockState pState, @Nullable ItemStack pStack) { + return new LaserPipeNet.LaserData(BlockPos.ZERO, Direction.NORTH, 0, LaserPipeProperties.INSTANCE, (byte) 0); + } + + @Override + public LaserPipeNet.LaserData getFallbackType() { + return new LaserPipeNet.LaserData(BlockPos.ZERO, Direction.NORTH, 0, LaserPipeProperties.INSTANCE, (byte) 0); + } + + @Override + public @Nullable PipeBlockRenderer getRenderer(BlockState state) { + return renderer; + } + + @Override + protected PipeModel getPipeModel() { + return model; + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/blockentity/LaserPipeBlockEntity.java b/common/src/main/java/com/gregtechceu/gtceu/common/blockentity/LaserPipeBlockEntity.java new file mode 100644 index 0000000000..5811fa7a4a --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/blockentity/LaserPipeBlockEntity.java @@ -0,0 +1,182 @@ +package com.gregtechceu.gtceu.common.blockentity; + +import com.gregtechceu.gtceu.api.blockentity.PipeBlockEntity; +import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; +import com.gregtechceu.gtceu.api.capability.ILaserContainer; +import com.gregtechceu.gtceu.api.item.tool.GTToolType; +import com.gregtechceu.gtceu.common.pipelike.laser.LaserNetHandler; +import com.gregtechceu.gtceu.common.pipelike.laser.LaserPipeNet; +import com.gregtechceu.gtceu.common.pipelike.laser.LaserPipeType; +import com.gregtechceu.gtceu.common.pipelike.laser.LevelLaserPipeNet; +import com.gregtechceu.gtceu.utils.TaskHandler; +import com.lowdragmc.lowdraglib.syncdata.annotation.DescSynced; +import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted; +import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; +import dev.architectury.injectables.annotations.ExpectPlatform; +import lombok.Getter; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; + +import java.lang.ref.WeakReference; +import java.util.EnumMap; + +public class LaserPipeBlockEntity extends PipeBlockEntity { + public static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(LaserPipeBlockEntity.class, PipeBlockEntity.MANAGED_FIELD_HOLDER); + + @Getter + protected final EnumMap handlers = new EnumMap<>(Direction.class); + // the LaserNetHandler can only be created on the server, so we have an empty placeholder for the client + public final ILaserContainer clientCapability = new DefaultLaserContainer(); + private WeakReference currentPipeNet = new WeakReference<>(null); + @Getter + protected LaserNetHandler defaultHandler; + + private int ticksActive = 0; + private int activeDuration = 0; + @Getter + @Persisted @DescSynced + private boolean active = false; + + protected LaserPipeBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { + super(type, pos, blockState); + } + + @ExpectPlatform + public static LaserPipeBlockEntity create(BlockEntityType type, BlockPos pos, BlockState blockState) { + throw new AssertionError(); + } + + @ExpectPlatform + public static void onBlockEntityRegister(BlockEntityType cableBlockEntityBlockEntityType) { + throw new AssertionError(); + } + + public void initHandlers() { + LaserPipeNet net = getLaserPipeNet(); + if (net == null) return; + for (Direction facing : Direction.values()) { + handlers.put(facing, new LaserNetHandler(net, this, facing)); + } + defaultHandler = new LaserNetHandler(net, this, null); + } + + public void checkNetwork() { + if (defaultHandler != null) { + LaserPipeNet current = getLaserPipeNet(); + if (defaultHandler.getNet() != current) { + defaultHandler.updateNetwork(current); + for (LaserNetHandler handler : handlers.values()) { + handler.updateNetwork(current); + } + } + } + } + + public LaserPipeNet getLaserPipeNet() { + if (level == null || level.isClientSide) { + return null; + } + LaserPipeNet currentPipeNet = this.currentPipeNet.get(); + if (currentPipeNet != null && currentPipeNet.isValid() && currentPipeNet.containsNode(getPipePos())) { + return currentPipeNet; + } + LevelLaserPipeNet worldNet = (LevelLaserPipeNet) getPipeBlock().getWorldPipeNet((ServerLevel) getPipeLevel()); + currentPipeNet = worldNet.getNetFromPos(getPipePos()); + if (currentPipeNet != null) { + this.currentPipeNet = new WeakReference<>(currentPipeNet); + } + return currentPipeNet; + } + + /** + * @param active if the pipe should become active + * @param duration how long the pipe should be active for + */ + public void setActive(boolean active, int duration) { + boolean stateChanged = false; + if (this.active && !active) { + this.active = false; + stateChanged = true; + } else if (!this.active && active) { + this.active = true; + stateChanged = true; + activeDuration = duration; + TaskHandler.enqueueServerTask((ServerLevel) getLevel(), () -> { + if (++this.ticksActive % activeDuration == 0) { + this.ticksActive = 0; + setActive(false, -1); + } + }, 0); + } else if (this.active) { + this.ticksActive = 0; + this.activeDuration = duration; + } + + if (stateChanged) { + notifyBlockUpdate(); + setChanged(); + } + } + + @Override + public boolean canAttachTo(Direction side) { + if (level != null) { + if (level.getBlockEntity(getBlockPos().relative(side)) instanceof LaserPipeBlockEntity) { + return false; + } + return GTCapabilityHelper.getLaser(level, getBlockPos().relative(side), side.getOpposite()) != null; + } + return false; + } + + @Override + protected boolean canToolTunePipe(GTToolType toolType) { + return toolType == GTToolType.WIRE_CUTTER; + } + + @Override + public ManagedFieldHolder getFieldHolder() { + return MANAGED_FIELD_HOLDER; + } + + private static class DefaultLaserContainer implements ILaserContainer { + + @Override + public long acceptEnergyFromNetwork(Direction side, long voltage, long amperage) { + return 0; + } + + @Override + public boolean inputsEnergy(Direction side) { + return false; + } + + @Override + public long changeEnergy(long differenceAmount) { + return 0; + } + + @Override + public long getEnergyStored() { + return 0; + } + + @Override + public long getEnergyCapacity() { + return 0; + } + + @Override + public long getInputAmperage() { + return 0; + } + + @Override + public long getInputVoltage() { + return 0; + } + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBlockEntities.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBlockEntities.java index e3635a6499..6e2a9d777a 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBlockEntities.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBlockEntities.java @@ -3,6 +3,7 @@ import com.gregtechceu.gtceu.common.blockentity.CableBlockEntity; import com.gregtechceu.gtceu.common.blockentity.FluidPipeBlockEntity; import com.gregtechceu.gtceu.common.blockentity.ItemPipeBlockEntity; +import com.gregtechceu.gtceu.common.blockentity.LaserPipeBlockEntity; import com.tterrag.registrate.util.entry.BlockEntityEntry; import com.tterrag.registrate.util.entry.BlockEntry; @@ -35,6 +36,12 @@ public class GTBlockEntities { .validBlocks(GTBlocks.ITEM_PIPE_BLOCKS.values().toArray(BlockEntry[]::new)) .register(); + public static final BlockEntityEntry LASER_PIPE = REGISTRATE + .blockEntity("laser_pipe", LaserPipeBlockEntity::create) + .onRegister(LaserPipeBlockEntity::onBlockEntityRegister) + .validBlocks(GTBlocks.LASER_PIPES) + .register(); + public static void init() { } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBlocks.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBlocks.java index 3b93012abb..dff4103746 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBlocks.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBlocks.java @@ -14,6 +14,7 @@ import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.api.data.tag.TagUtil; +import com.gregtechceu.gtceu.api.item.LaserPipeBlockItem; import com.gregtechceu.gtceu.api.item.MaterialBlockItem; import com.gregtechceu.gtceu.api.item.MaterialPipeBlockItem; import com.gregtechceu.gtceu.api.item.RendererBlockItem; @@ -57,6 +58,7 @@ import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; import net.minecraft.util.RandomSource; +import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.FoliageColor; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.*; @@ -301,6 +303,35 @@ public static void generatePipeBlocks() { ITEM_PIPE_BLOCKS = itemsBuilder.build(); } + + + + ////////////////////////////////////// + //***** General Pipes ******// + ////////////////////////////////////// + public static final BlockEntry[] LASER_PIPES = new BlockEntry[DyeColor.values().length]; + + public static void generateLaserPipeBlocks() { + REGISTRATE.creativeModeTab(() -> GTCreativeModeTabs.MATERIAL_PIPE); + + for (int i = 0; i < DyeColor.values().length; ++i) { + var color = DyeColor.values()[i]; + LASER_PIPES[i] = REGISTRATE.block("%s_laser_pipe".formatted(color.getSerializedName()), p -> new LaserPipeBlock(p, color)) + .initialProperties(() -> Blocks.IRON_BLOCK) + .properties(p -> p.dynamicShape().noOcclusion().noLootTable()) + .blockstate(NonNullBiConsumer.noop()) + .setData(ProviderType.LANG, NonNullBiConsumer.noop()) + .setData(ProviderType.LOOT, NonNullBiConsumer.noop()) + .addLayer(() -> RenderType::cutoutMipped) + .color(() -> LaserPipeBlock::tintedColor) + .item(LaserPipeBlockItem::new) + .model(NonNullBiConsumer.noop()) + .color(() -> LaserPipeBlockItem::tintColor) + .build() + .register(); + } + } + public static final BlockEntry LD_ITEM_PIPE = REGISTRATE.block("long_distance_item_pipeline", properties -> new LongDistancePipeBlock(properties, LDItemPipeType.INSTANCE)) .initialProperties(() -> Blocks.IRON_BLOCK) .blockstate(GTModels::longDistanceItemPipeModel) @@ -490,6 +521,10 @@ public static void generatePipeBlocks() { public static final BlockEntry FIREBOX_TUNGSTENSTEEL = createFireboxCasing(BoilerFireboxType.TUNGSTENSTEEL_FIREBOX); + // HPCA, AT + public static final BlockEntry HIGH_POWER_CASING = createCasingBlock("high_power_casing", GTCEu.id("block/casings/hpca/high_power_casing")); + + private static BlockEntry createPipeCasingBlock(String name, ResourceLocation texture) { return createPipeCasingBlock(name, texture, () -> Blocks.IRON_BLOCK); @@ -791,6 +826,7 @@ public static void init() { generateMaterialBlocks(); generateCableBlocks(); generatePipeBlocks(); + generateLaserPipeBlocks(); GCyMBlocks.init(); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java index 13c2986917..f9be023304 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java @@ -4,8 +4,6 @@ import appeng.core.AEConfig; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; -import com.gregtechceu.gtceu.api.addon.AddonFinder; -import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.api.block.MetaMachineBlock; import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; import com.gregtechceu.gtceu.api.capability.IMiner; @@ -33,6 +31,7 @@ import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; import com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder; +import com.gregtechceu.gtceu.client.TooltipHelper; import com.gregtechceu.gtceu.client.renderer.machine.*; import com.gregtechceu.gtceu.common.block.BoilerFireboxType; import com.gregtechceu.gtceu.common.machine.electric.*; @@ -250,9 +249,9 @@ public class GTMachines { .rotationState(RotationState.ALL) .tier(LV) .renderer(() -> new TieredHullMachineRenderer(LV, GTCEu.id("block/machine/ld_fluid_endpoint_machine"))) - .tooltips(Component.translatable("gtceu.machine.endpoint.tooltip.1"), - Component.translatable("gtceu.machine.endpoint.tooltip.2"), - Component.translatable("gtceu.machine.endpoint.tooltip.3")) + .tooltips(Component.translatable("gtceu.machine.endpoint.tooltip.0"), + Component.translatable("gtceu.machine.endpoint.tooltip.1"), + Component.translatable("gtceu.machine.endpoint.tooltip.2")) .tooltipBuilder((stack, tooltip) -> { if (ConfigHolder.INSTANCE.machines.ldFluidPipeMinDistance > 0) { tooltip.add(Component.translatable("gtceu.machine.endpoint.tooltip.min_length", ConfigHolder.INSTANCE.machines.ldItemPipeMinDistance)); @@ -713,6 +712,13 @@ public static BiConsumer> createTankTooltips(String n .register(), HV, EV, IV, LuV, ZPM, UV); + public static final MachineDefinition[] LASER_INPUT_HATCH_256 = registerLaserHatch(IO.IN, 256, PartAbility.INPUT_LASER); + public static final MachineDefinition[] LASER_OUTPUT_HATCH_256 = registerLaserHatch(IO.OUT, 256, PartAbility.OUTPUT_LASER); + public static final MachineDefinition[] LASER_INPUT_HATCH_1024 = registerLaserHatch(IO.IN, 1024, PartAbility.INPUT_LASER); + public static final MachineDefinition[] LASER_OUTPUT_HATCH_1024 = registerLaserHatch(IO.OUT, 1024, PartAbility.OUTPUT_LASER); + public static final MachineDefinition[] LASER_INPUT_HATCH_4096 = registerLaserHatch(IO.IN, 4096, PartAbility.INPUT_LASER); + public static final MachineDefinition[] LASER_OUTPUT_HATCH_4096 = registerLaserHatch(IO.OUT, 4096, PartAbility.OUTPUT_LASER); + ////////////////////////////////////// //******* Multiblock *******// @@ -1425,6 +1431,27 @@ public static BiConsumer> createTankTooltips(String n .register(), IV, LuV) : null; + public static final MultiblockMachineDefinition ACTIVE_TRANSFORMER = REGISTRATE.multiblock("active_transformer", ActiveTransformerMachine::new) + .rotationState(RotationState.NON_Y_AXIS) + .recipeType(GTRecipeTypes.DUMMY_RECIPES) + .tooltips(Component.translatable("gtceu.machine.active_transformer.tooltip.0"), + Component.translatable("gtceu.machine.active_transformer.tooltip.1"), + Component.translatable("gtceu.machine.active_transformer.tooltip.2") + .append(Component.translatable("gtceu.machine.active_transformer.tooltip.3") + .withStyle(TooltipHelper.RAINBOW_SLOW.getCurrent()))) + .pattern((definition) -> FactoryBlockPattern.start() + .aisle("XXX", "XXX", "XXX") + .aisle("XXX", "XCX", "XXX") + .aisle("XXX", "XSX", "XXX") + .where('S', controller(blocks(definition.getBlock()))) + .where('X', blocks(GTBlocks.HIGH_POWER_CASING.get()).setMinGlobalLimited(12) + .or(ActiveTransformerMachine.getHatchPredicates())) + .where('C', blocks(GTBlocks.SUPERCONDUCTING_COIL.get())) + .build()) + .workableCasingRenderer(GTCEu.id("block/casings/hpca/high_power_casing"), + GTCEu.id("block/multiblock/data_bank"), false) + .register(); + ////////////////////////////////////// //********** Misc **********// @@ -1561,6 +1588,18 @@ public static MachineDefinition[] registerCharger(int itemSlotSize) { ALL_TIERS); } + public static MachineDefinition[] registerLaserHatch(IO io, int amperage, PartAbility ability) { + String name = io == IO.IN ? "target" : "source"; + return registerTieredMachines(amperage + "a_laser_" + name + "_hatch", (holder, tier) -> new LaserHatchPartMachine(holder, io, tier, amperage), (tier, builder) -> builder + .rotationState(RotationState.ALL) + .tooltips(Component.translatable("gtceu.machine.laser_hatch." + name + ".tooltip.0"), + Component.translatable("gtceu.machine.laser_hatch." + name + ".tooltip.1"), + Component.translatable("gtceu.universal.disabled")) + .abilities(ability) + .overlayTieredHullRenderer("laser_hatch." + name) + .register(), HIGH_TIERS); + } + public static MultiblockMachineDefinition[] registerTieredMultis(String name, BiFunction factory, BiFunction builder, diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/ActiveTransformerMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/ActiveTransformerMachine.java new file mode 100644 index 0000000000..ab3e8447f5 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/ActiveTransformerMachine.java @@ -0,0 +1,108 @@ +package com.gregtechceu.gtceu.common.machine.multiblock.electric; + +import com.gregtechceu.gtceu.api.capability.IControllable; +import com.gregtechceu.gtceu.api.capability.IEnergyContainer; +import com.gregtechceu.gtceu.api.capability.recipe.EURecipeCapability; +import com.gregtechceu.gtceu.api.capability.recipe.IO; +import com.gregtechceu.gtceu.api.machine.ConditionalSubscriptionHandler; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; +import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiPart; +import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility; +import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine; +import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; +import com.gregtechceu.gtceu.api.misc.EnergyContainerList; +import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate; +import it.unimi.dsi.fastutil.longs.Long2ObjectMaps; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static com.gregtechceu.gtceu.api.pattern.Predicates.abilities; + +public class ActiveTransformerMachine extends WorkableElectricMultiblockMachine implements IControllable { + + + private IEnergyContainer powerOutput; + private IEnergyContainer powerInput; + protected ConditionalSubscriptionHandler converterSubscription; + + public ActiveTransformerMachine(IMachineBlockEntity holder) { + super(holder); + this.powerOutput = new EnergyContainerList(new ArrayList<>()); + this.powerInput = new EnergyContainerList(new ArrayList<>()); + this.converterSubscription = new ConditionalSubscriptionHandler(this, this::convertEnergyTick, this::isSubscriptionActive); + } + + public void convertEnergyTick() { + getRecipeLogic().setStatus(RecipeLogic.Status.WORKING); + if (isWorkingEnabled()) { + long canDrain = powerInput.getEnergyStored(); + long totalDrained = powerOutput.changeEnergy(canDrain); + powerInput.removeEnergy(totalDrained); + } + converterSubscription.updateSubscription(); + } + + protected boolean isSubscriptionActive() { + if (powerInput != null && powerInput.getEnergyStored() > 0) + return true; + + if (powerOutput == null) + return false; + + if (powerOutput.getEnergyStored() <= 0) + return false; + + return powerOutput.getEnergyStored() < powerOutput.getEnergyCapacity(); + } + + @Override + public void onStructureFormed() { + super.onStructureFormed(); + // capture all energy containers + List powerInput = new ArrayList<>(); + List powerOutput = new ArrayList<>(); + Map ioMap = getMultiblockState().getMatchContext().getOrCreate("ioMap", Long2ObjectMaps::emptyMap); + for (IMultiPart part : getParts()) { + IO io = ioMap.getOrDefault(part.self().getPos().asLong(), IO.BOTH); + if (io == IO.NONE) continue; + for (var handler : part.getRecipeHandlers()) { + var handlerIO = handler.getHandlerIO(); + // If IO not compatible + if (io != IO.BOTH && handlerIO != IO.BOTH && io != handlerIO) continue; + if (handler.getCapability() == EURecipeCapability.CAP && handler instanceof IEnergyContainer container) { + if (handlerIO == IO.IN) { + powerInput.add(container); + } else if (handlerIO == IO.OUT) { + powerOutput.add(container); + } + traitSubscriptions.add(handler.addChangedListener(converterSubscription::updateSubscription)); + } + } + } + + // Invalidate the structure if there is not at least one output and one input + if (powerInput.isEmpty() || powerOutput.isEmpty()) { + this.onStructureInvalid(); + } + + this.powerOutput = new EnergyContainerList(powerOutput); + this.powerInput = new EnergyContainerList(powerInput); + } + + @Override + public void onStructureInvalid() { + super.onStructureInvalid(); + this.powerOutput = new EnergyContainerList(new ArrayList<>()); + this.powerInput = new EnergyContainerList(new ArrayList<>()); + getRecipeLogic().setStatus(RecipeLogic.Status.IDLE); + } + + public static TraceabilityPredicate getHatchPredicates() { + return abilities(PartAbility.INPUT_ENERGY).setPreviewCount(1) + .or(abilities(PartAbility.OUTPUT_ENERGY).setPreviewCount(2)) + .or(abilities(PartAbility.INPUT_LASER).setPreviewCount(1)) + .or(abilities(PartAbility.OUTPUT_LASER).setPreviewCount(1)); + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/EnergyHatchPartMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/EnergyHatchPartMachine.java index fa99a0b29f..96f081126c 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/EnergyHatchPartMachine.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/EnergyHatchPartMachine.java @@ -13,6 +13,9 @@ import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; import lombok.Getter; import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.BlockHitResult; import org.jetbrains.annotations.Nullable; import javax.annotation.ParametersAreNonnullByDefault; @@ -64,6 +67,11 @@ protected NotifiableEnergyContainer createEnergyContainer(Object... args) { return container; } + @Override + public boolean shouldOpenUI(Player player, InteractionHand hand, BlockHitResult hit) { + return false; + } + @Override public void onLoad() { super.onLoad(); diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/LaserHatchPartMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/LaserHatchPartMachine.java new file mode 100644 index 0000000000..465ca7467c --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/LaserHatchPartMachine.java @@ -0,0 +1,61 @@ +package com.gregtechceu.gtceu.common.machine.multiblock.part; + +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; +import com.gregtechceu.gtceu.api.capability.ILaserContainer; +import com.gregtechceu.gtceu.api.capability.recipe.IO; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiController; +import com.gregtechceu.gtceu.api.machine.multiblock.part.MultiblockPartMachine; +import com.gregtechceu.gtceu.api.machine.multiblock.part.TieredIOPartMachine; +import com.gregtechceu.gtceu.api.machine.trait.NotifiableLaserContainer; +import com.gregtechceu.gtceu.common.machine.multiblock.electric.ActiveTransformerMachine; +import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted; +import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; +import lombok.Setter; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.BlockHitResult; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.Collection; +import java.util.function.Supplier; + +@ParametersAreNonnullByDefault +public class LaserHatchPartMachine extends TieredIOPartMachine { + protected static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(TieredIOPartMachine.class, MultiblockPartMachine.MANAGED_FIELD_HOLDER); + + @Persisted + private NotifiableLaserContainer buffer; + + public LaserHatchPartMachine(IMachineBlockEntity holder, IO io, int tier, int amperage) { + super(holder, tier, io); + if (io == IO.OUT) { + this.buffer = NotifiableLaserContainer.emitterContainer(this, GTValues.V[tier] * 64L * amperage, GTValues.V[tier], amperage); + this.buffer.setSideOutputCondition(s -> s == getFrontFacing()); + } else { + this.buffer = NotifiableLaserContainer.receiverContainer(this, GTValues.V[tier] * 64L * amperage, GTValues.V[tier], amperage); + this.buffer.setSideInputCondition(s -> s == getFrontFacing()); + } + } + + @Override + public boolean shouldOpenUI(Player player, InteractionHand hand, BlockHitResult hit) { + return false; + } + + @Override + public boolean canShared() { + return false; + } + + @Override + public ManagedFieldHolder getFieldHolder() { + return MANAGED_FIELD_HOLDER; + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/LargeBoilerMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/LargeBoilerMachine.java index f508551fc0..3bb985b502 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/LargeBoilerMachine.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/LargeBoilerMachine.java @@ -13,6 +13,7 @@ import com.gregtechceu.gtceu.api.machine.multiblock.WorkableMultiblockMachine; import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient; +import com.gregtechceu.gtceu.common.data.GTMaterials; import com.gregtechceu.gtceu.data.recipe.CustomTags; import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; import com.lowdragmc.lowdraglib.gui.util.ClickData; @@ -127,7 +128,7 @@ protected void updateCurrentTemperature() { if (hasDrainedWater) { // fill steam - var fillSteam = List.of(FluidIngredient.of(CustomTags.STEAM, drained * STEAM_PER_WATER)); + var fillSteam = List.of(FluidIngredient.of(GTMaterials.Steam.getFluid(drained * STEAM_PER_WATER))); List> outputTanks = new ArrayList<>(); if (getCapabilitiesProxy().contains(IO.OUT, FluidRecipeCapability.CAP)) { outputTanks.addAll(Objects.requireNonNull(getCapabilitiesProxy().get(IO.OUT, FluidRecipeCapability.CAP))); diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamMinerMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamMinerMachine.java index 067fa66d85..899c6a78e2 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamMinerMachine.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamMinerMachine.java @@ -17,6 +17,7 @@ import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.common.data.GTMaterials; import com.gregtechceu.gtceu.common.machine.trait.miner.SteamMinerLogic; +import com.gregtechceu.gtceu.data.recipe.CustomTags; import com.lowdragmc.lowdraglib.gui.modular.ModularUI; import com.lowdragmc.lowdraglib.gui.widget.ComponentPanelWidget; import com.lowdragmc.lowdraglib.gui.widget.ImageWidget; @@ -87,7 +88,7 @@ public SteamMinerLogic getRecipeLogic() { @Override protected NotifiableFluidTank createSteamTank(Object... args) { - return new NotifiableFluidTank(this, 1, 16 * FluidHelper.getBucket(), IO.IN).setFilter(fluidStack -> fluidStack.getFluid().isSame(GTMaterials.Steam.getFluid())); + return new NotifiableFluidTank(this, 1, 16 * FluidHelper.getBucket(), IO.IN); } protected NotifiableItemStackHandler createImportItemHandler(@SuppressWarnings("unused") Object... args) { diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserNetHandler.java b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserNetHandler.java new file mode 100644 index 0000000000..4babd5343b --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserNetHandler.java @@ -0,0 +1,113 @@ +package com.gregtechceu.gtceu.common.pipelike.laser; + +import com.gregtechceu.gtceu.api.capability.ILaserContainer; +import com.gregtechceu.gtceu.common.blockentity.LaserPipeBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class LaserNetHandler implements ILaserContainer { + private LaserPipeNet net; + private final LaserPipeBlockEntity pipe; + private final Direction facing; + private final Level world; + + public LaserNetHandler(LaserPipeNet net, @Nonnull LaserPipeBlockEntity pipe, @Nullable Direction facing) { + this.net = net; + this.pipe = pipe; + this.facing = facing; + this.world = pipe.getLevel(); + } + + public void updateNetwork(LaserPipeNet net) { + this.net = net; + } + + private void setPipesActive() { + for (BlockPos pos : net.getAllNodes().keySet()) { + if (world.getBlockEntity(pos) instanceof LaserPipeBlockEntity laserPipe) { + laserPipe.setActive(true, 100); + } + } + } + + @Nullable + private ILaserContainer getInnerContainer() { + if (net == null || pipe == null || pipe.isInValid() || (facing == null || pipe.isBlocked(facing))) { + return null; + } + + LaserPipeNet.LaserData data = net.getNetData(pipe.getPipePos(), facing); + if (data == null) { + return null; + } + + return data.getHandler(world); + } + + @Override + public long acceptEnergyFromNetwork(Direction side, long voltage, long amperage) { + ILaserContainer handler = getInnerContainer(); + if (handler == null) return 0; + setPipesActive(); + return handler.acceptEnergyFromNetwork(side, voltage, amperage); + } + + @Override + public boolean inputsEnergy(Direction side) { + ILaserContainer handler = getInnerContainer(); + if (handler == null) return false; + return handler.inputsEnergy(side); + } + + @Override + public boolean outputsEnergy(Direction side) { + ILaserContainer handler = getInnerContainer(); + if (handler == null) return false; + return handler.outputsEnergy(side); + } + + @Override + public long changeEnergy(long amount) { + ILaserContainer handler = getInnerContainer(); + if (handler == null) return 0; + setPipesActive(); + return handler.changeEnergy(amount); + } + + @Override + public long getEnergyStored() { + ILaserContainer handler = getInnerContainer(); + if (handler == null) return 0; + return handler.getEnergyStored(); + } + + @Override + public long getEnergyCapacity() { + ILaserContainer handler = getInnerContainer(); + if (handler == null) return 0; + return handler.getEnergyCapacity(); + } + + @Override + public long getInputAmperage() { + return 0; + } + + @Override + public long getInputVoltage() { + return 0; + } + + public LaserPipeNet getNet() { + return net; + } + + @Override + public boolean isOneProbeHidden() { + return true; + } +} \ No newline at end of file diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserNetWalker.java b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserNetWalker.java new file mode 100644 index 0000000000..e710c6f830 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserNetWalker.java @@ -0,0 +1,73 @@ +package com.gregtechceu.gtceu.common.pipelike.laser; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; +import com.gregtechceu.gtceu.api.capability.ILaserContainer; +import com.lowdragmc.lowdraglib.pipelike.Node; +import com.lowdragmc.lowdraglib.pipelike.PipeNetWalker; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class LaserNetWalker extends PipeNetWalker { + + @Nullable + public static LaserPipeNet.LaserData createNetData(LaserPipeNet world, BlockPos sourcePipe, Direction faceToSourceHandler) { + try { + LaserNetWalker walker = new LaserNetWalker(world, sourcePipe, 1, null, null); + walker.sourcePipe = sourcePipe; + walker.facingToHandler = faceToSourceHandler; + walker.axis = faceToSourceHandler.getAxis(); + walker.traversePipeNet(); + return walker.laserData; + } catch (Exception e) { + GTCEu.LOGGER.error("error while create net data for LaserPipeNet", e); + } + return null; + } + + private LaserPipeProperties minProperties; + private LaserPipeNet.LaserData laserData; + private BlockPos sourcePipe; + private Direction facingToHandler; + private Direction.Axis axis; + + protected LaserNetWalker(LaserPipeNet world, BlockPos sourcePipe, int distance, LaserPipeNet.LaserData laserData, LaserPipeProperties properties) { + super(world, sourcePipe, distance); + this.laserData = laserData; + this.minProperties = properties; + } + + @Nonnull + @Override + protected LaserNetWalker createSubWalker(LaserPipeNet world, BlockPos nextPos, int walkedBlocks) { + LaserNetWalker walker = new LaserNetWalker(world, nextPos, walkedBlocks, laserData, minProperties); + walker.facingToHandler = facingToHandler; + walker.sourcePipe = sourcePipe; + walker.axis = axis; + return walker; + } + + @Override + protected boolean checkPipe(Node pipeTile, BlockPos pos) { + LaserPipeProperties pipeProperties = pipeTile.data.getProperties(); + if (minProperties == null) { + minProperties = pipeProperties; + } else { + minProperties = new LaserPipeProperties(pipeProperties); + } + return true; + } + + @Override + protected void checkNeighbour(Node pipeNode, BlockPos pipePos, Direction faceToNeighbour) { + if (pipeNode.data.canAttachTo(faceToNeighbour) && laserData == null && (!sourcePipe.equals(pipePos) && faceToNeighbour != facingToHandler)) { + ILaserContainer handler = GTCapabilityHelper.getLaser(getLevel(), pipePos, faceToNeighbour.getOpposite()); + if (handler != null) { + laserData = new LaserPipeNet.LaserData(new BlockPos(pipePos), faceToNeighbour, getWalkedBlocks(), LaserPipeProperties.INSTANCE, (byte) 0); + } + } + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserPipeNet.java b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserPipeNet.java new file mode 100644 index 0000000000..fc7f2b5580 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserPipeNet.java @@ -0,0 +1,138 @@ +package com.gregtechceu.gtceu.common.pipelike.laser; + +import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; +import com.gregtechceu.gtceu.api.capability.ILaserContainer; +import com.gregtechceu.gtceu.api.pipenet.IAttachData; +import com.lowdragmc.lowdraglib.pipelike.Node; +import com.lowdragmc.lowdraglib.pipelike.PipeNet; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import lombok.AllArgsConstructor; +import lombok.Getter; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.level.Level; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Map; + +public class LaserPipeNet extends PipeNet { + + private final Map netData = new Object2ObjectOpenHashMap<>(); + + public LaserPipeNet(LevelLaserPipeNet world) { + super(world); + } + + @Nullable + public LaserData getNetData(BlockPos pipePos, Direction facing) { + LaserData data = netData.get(pipePos); + if (data == null) { + data = LaserNetWalker.createNetData(this, pipePos, facing); + if (data == null) { + // walker failed, don't cache, so it tries again on next insertion + return null; + } + + netData.put(pipePos, data); + } + return data; + } + + @Override + public void onNeighbourUpdate(BlockPos fromPos) { + netData.clear(); + } + + @Override + public void onPipeConnectionsUpdate() { + netData.clear(); + } + + @Override + protected void transferNodeData(Map> transferredNodes, PipeNet parentNet) { + super.transferNodeData(transferredNodes, parentNet); + netData.clear(); + ((LaserPipeNet) parentNet).netData.clear(); + } + + @Override + protected void writeNodeData(LaserData nodeData, CompoundTag tagCompound) { + tagCompound.put("pipePos", NbtUtils.writeBlockPos(nodeData.getPipePos())); + tagCompound.putByte("faceToHandler", (byte) nodeData.faceToHandler.ordinal()); + tagCompound.putInt("distance", nodeData.distance); + tagCompound.putByte("connections", nodeData.connections); + } + + @Override + protected LaserData readNodeData(CompoundTag tagCompound) { + BlockPos pipePos = NbtUtils.readBlockPos(tagCompound.getCompound("pipePos")); + Direction direction = Direction.values()[tagCompound.getByte("faceToHandler")]; + int distance = tagCompound.getInt("distance"); + return new LaserData(pipePos, direction, distance, LaserPipeProperties.INSTANCE, tagCompound.getByte("connections")); + } + + @AllArgsConstructor + public static class LaserData implements IAttachData { + /** + * The current position of the pipe + */ + @Getter + private final BlockPos pipePos; + /** + * The current face to handler + */ + @Getter + private final Direction faceToHandler; + /** + * The manhattan distance traveled during walking + */ + @Getter + private final int distance; + /** + * The laser pipe properties of the current pipe + */ + @Getter + private final LaserPipeProperties properties; + @Getter + byte connections; + + @Override + public boolean canAttachTo(Direction side) { + return (connections & (1 << side.ordinal())) != 0 && side.getAxis() == this.faceToHandler.getAxis(); + } + + @Override + public boolean setAttached(Direction side, boolean attach) { + var result = canAttachTo(side); + if (result != attach) { + if (attach) { + connections |= (1 << side.ordinal()); + } else { + connections &= ~(1 << side.ordinal()); + } + } + return result != attach; + } + + /** + * @return The position of where the handler would be + */ + @Nonnull + public BlockPos getHandlerPos() { + return pipePos.relative(faceToHandler); + } + + /** + * Gets the handler if it exists + * @param world the world to get the handler from + * @return the handler + */ + @Nullable + public ILaserContainer getHandler(@Nonnull Level world) { + return GTCapabilityHelper.getLaser(world, getHandlerPos(), faceToHandler.getOpposite()); + } + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserPipeProperties.java b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserPipeProperties.java new file mode 100644 index 0000000000..618a49ca2c --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserPipeProperties.java @@ -0,0 +1,16 @@ +package com.gregtechceu.gtceu.common.pipelike.laser; + +import lombok.NoArgsConstructor; +import lombok.RequiredArgsConstructor; +import net.minecraft.core.Direction; + +import javax.annotation.Nonnull; + +@NoArgsConstructor +public class LaserPipeProperties { + public static final LaserPipeProperties INSTANCE = new LaserPipeProperties(); + + public LaserPipeProperties(LaserPipeProperties other) { + + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserPipeType.java b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserPipeType.java new file mode 100644 index 0000000000..b41fdab78f --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LaserPipeType.java @@ -0,0 +1,31 @@ +package com.gregtechceu.gtceu.common.pipelike.laser; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.pipenet.IPipeType; +import net.minecraft.resources.ResourceLocation; + +public enum LaserPipeType implements IPipeType { + NORMAL; + + public static final ResourceLocation TYPE_ID = GTCEu.id("laser"); + + @Override + public float getThickness() { + return 0.375f; + } + + @Override + public LaserPipeNet.LaserData modifyProperties(LaserPipeNet.LaserData baseProperties) { + return baseProperties; + } + + @Override + public boolean isPaintable() { + return true; + } + + @Override + public ResourceLocation type() { + return TYPE_ID; + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LevelLaserPipeNet.java b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LevelLaserPipeNet.java new file mode 100644 index 0000000000..9a1eb51796 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/laser/LevelLaserPipeNet.java @@ -0,0 +1,26 @@ +package com.gregtechceu.gtceu.common.pipelike.laser; + +import com.lowdragmc.lowdraglib.pipelike.LevelPipeNet; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; + +public class LevelLaserPipeNet extends LevelPipeNet { + private static final String DATA_ID = "gtceu_laser_pipe_net"; + + public static LevelLaserPipeNet getOrCreate(ServerLevel serverLevel) { + return serverLevel.getDataStorage().computeIfAbsent(tag -> new LevelLaserPipeNet(serverLevel, tag), () -> new LevelLaserPipeNet(serverLevel), DATA_ID); + } + + public LevelLaserPipeNet(ServerLevel serverLevel) { + super(serverLevel); + } + + public LevelLaserPipeNet(ServerLevel serverLevel, CompoundTag tag) { + super(serverLevel, tag); + } + + @Override + protected LaserPipeNet createNetInstance() { + return new LaserPipeNet(this); + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/lang/LangHandler.java b/common/src/main/java/com/gregtechceu/gtceu/data/lang/LangHandler.java index a96cbb582c..0369c6bf6e 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/lang/LangHandler.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/lang/LangHandler.java @@ -696,6 +696,31 @@ public static void init(RegistrateLangProvider provider) { provider.add("gtceu.machine.available_recipe_map_3.tooltip", "Available Recipe Maps: %s, %s, %s"); provider.add("gtceu.machine.available_recipe_map_4.tooltip", "Available Recipe Maps: %s, %s, %s, %s"); + multiLang(provider, "gtceu.machine.power_substation.tooltip", + "The heart of a centralized power grid", + "§fCapacitors§7 do not need to be all the same tier.", + "Allows up to §f%d Capacitor Layers§7.", + "Loses energy equal to §f1%%§7 of total capacity every §f24 hours§7.", + "Capped at §f%,d EU/t§7 passive loss per Capacitor Block." + ); + + multiLang(provider, "gtceu.machine.active_transformer.tooltip", + "Transformers: Lasers in Disguise", + "Can combine any number of Energy §fInputs§7 into any number of Energy §fOutputs§7.", + "Can transmit power at incredible distance with", + "Lasers§7." + ); + + multiLang(provider, "gtceu.machine.laser_hatch.source.tooltip", + "Transmitting power at distance", + "§cLaser Cables must be in a straight line!§7" + ); + + multiLang(provider, "gtceu.machine.laser_hatch.target.tooltip", + "Receiving power from distance", + "§cLaser Cables must be in a straight line!§7" + ); + multiLang(provider, "gtceu.machine.endpoint.tooltip", "Connect with §fLong Distance Pipe§7 blocks to create a pipeline.", "Pipelines must have exactly §f1 Input§7 and §f1 Output§7 endpoint.", diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java index dba99adbaf..9872ecf9ea 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java @@ -1,13 +1,10 @@ package com.gregtechceu.gtceu.data.recipe.misc; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.stack.UnificationEntry; -import com.gregtechceu.gtceu.common.data.GTMachines; import com.gregtechceu.gtceu.data.recipe.CustomTags; import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper; import net.minecraft.data.recipes.FinishedRecipe; -import java.util.Arrays; import java.util.function.Consumer; import static com.gregtechceu.gtceu.api.GTValues.*; @@ -23,7 +20,8 @@ public class MetaTileEntityMachineRecipeLoader { public static void init(Consumer provider) { - + registerLaserRecipes(provider); + // Energy Output Hatches VanillaRecipeHelper.addShapedRecipe(provider, true, "dynamo_hatch_ulv", ENERGY_OUTPUT_HATCH[ULV].asStack(), @@ -253,108 +251,107 @@ public static void init(Consumer provider) { .duration(1000).EUt(VA[UHV]).save(provider); - // Adjustable Transformers - // TODO Adjustable transformers -/* - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(TRANSFORMER[ULV]) + + // Power Transformers + + ASSEMBLER_RECIPES.recipeBuilder("ulv_power_transformer") + .inputItems(HI_AMP_TRANSFORMER_4A[ULV]) .inputItems(ELECTRIC_PUMP_LV) - .inputItems(wireGtQuadruple, Tin) - .inputItems(wireGtOctal, Lead) + .inputItems(cableGtOctal, Tin) + .inputItems(cableGtHex, Lead, 2) .inputItems(springSmall, Lead) .inputItems(spring, Tin) .inputFluids(Lubricant.getFluid(2000)) - .outputItems(ADJUSTABLE_TRANSFORMER[ULV]) + .outputItems(POWER_TRANSFORMER[ULV]) .duration(200).EUt(VA[ULV]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(TRANSFORMER[LV]) + ASSEMBLER_RECIPES.recipeBuilder("lv_power_transformer") + .inputItems(HI_AMP_TRANSFORMER_4A[LV]) .inputItems(ELECTRIC_PUMP_LV) - .inputItems(wireGtQuadruple, Copper) - .inputItems(wireGtOctal, Tin) + .inputItems(cableGtOctal, Copper) + .inputItems(cableGtHex, Tin, 2) .inputItems(springSmall, Tin) .inputItems(spring, Copper) .inputFluids(Lubricant.getFluid(2000)) - .outputItems(ADJUSTABLE_TRANSFORMER[LV]) + .outputItems(POWER_TRANSFORMER[LV]) .duration(200).EUt(VA[LV]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(TRANSFORMER[MV]) + ASSEMBLER_RECIPES.recipeBuilder("mv_power_transformer") + .inputItems(HI_AMP_TRANSFORMER_4A[MV]) .inputItems(ELECTRIC_PUMP_MV) - .inputItems(wireGtQuadruple, Gold) - .inputItems(wireGtOctal, Copper) + .inputItems(cableGtOctal, Gold) + .inputItems(cableGtHex, Copper, 2) .inputItems(springSmall, Copper) .inputItems(spring, Gold) .inputFluids(Lubricant.getFluid(2000)) - .outputItems(ADJUSTABLE_TRANSFORMER[MV]) + .outputItems(POWER_TRANSFORMER[MV]) .duration(200).EUt(VA[MV]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(TRANSFORMER[HV]) + ASSEMBLER_RECIPES.recipeBuilder("hv_power_transformer") + .inputItems(HI_AMP_TRANSFORMER_4A[HV]) .inputItems(ELECTRIC_PUMP_MV) - .inputItems(wireGtQuadruple, Aluminium) - .inputItems(wireGtOctal, Gold) + .inputItems(cableGtOctal, Aluminium) + .inputItems(cableGtHex, Gold, 2) .inputItems(springSmall, Gold) .inputItems(spring, Aluminium) .inputFluids(Lubricant.getFluid(2000)) - .outputItems(ADJUSTABLE_TRANSFORMER[HV]) + .outputItems(POWER_TRANSFORMER[HV]) .duration(200).EUt(VA[HV]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(TRANSFORMER[EV]) + ASSEMBLER_RECIPES.recipeBuilder("ev_power_transformer") + .inputItems(HI_AMP_TRANSFORMER_4A[EV]) .inputItems(ELECTRIC_PUMP_HV) - .inputItems(wireGtQuadruple, Tungsten) - .inputItems(wireGtOctal, Aluminium) + .inputItems(cableGtOctal, Tungsten) + .inputItems(cableGtHex, Aluminium, 2) .inputItems(springSmall, Aluminium) .inputItems(spring, Tungsten) .inputFluids(Lubricant.getFluid(2000)) - .outputItems(ADJUSTABLE_TRANSFORMER[EV]) + .outputItems(POWER_TRANSFORMER[EV]) .duration(200).EUt(VA[EV]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(TRANSFORMER[IV]) + ASSEMBLER_RECIPES.recipeBuilder("iv_power_transformer") + .inputItems(HI_AMP_TRANSFORMER_4A[IV]) .inputItems(ELECTRIC_PUMP_HV) - .inputItems(wireGtQuadruple, NiobiumTitanium) - .inputItems(wireGtOctal, Tungsten) + .inputItems(cableGtOctal, NiobiumTitanium) + .inputItems(cableGtHex, Tungsten, 2) .inputItems(springSmall, Tungsten) .inputItems(spring, NiobiumTitanium) .inputFluids(Lubricant.getFluid(2000)) - .outputItems(ADJUSTABLE_TRANSFORMER[IV]) + .outputItems(POWER_TRANSFORMER[IV]) .duration(200).EUt(VA[IV]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(TRANSFORMER[LuV]) + ASSEMBLER_RECIPES.recipeBuilder("luv_power_transformer") + .inputItems(HI_AMP_TRANSFORMER_4A[LuV]) .inputItems(ELECTRIC_PUMP_EV) - .inputItems(wireGtQuadruple, VanadiumGallium) - .inputItems(wireGtOctal, NiobiumTitanium) + .inputItems(cableGtOctal, VanadiumGallium) + .inputItems(cableGtHex, NiobiumTitanium, 2) .inputItems(springSmall, NiobiumTitanium) .inputItems(spring, VanadiumGallium) .inputFluids(Lubricant.getFluid(2000)) - .outputItems(ADJUSTABLE_TRANSFORMER[LuV]) + .outputItems(POWER_TRANSFORMER[LuV]) .duration(200).EUt(VA[LuV]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(TRANSFORMER[ZPM]) + ASSEMBLER_RECIPES.recipeBuilder("zpm_power_transformer") + .inputItems(HI_AMP_TRANSFORMER_4A[ZPM]) .inputItems(ELECTRIC_PUMP_EV) - .inputItems(wireGtQuadruple, YttriumBariumCuprate) - .inputItems(wireGtOctal, VanadiumGallium) + .inputItems(cableGtOctal, YttriumBariumCuprate) + .inputItems(cableGtHex, VanadiumGallium, 2) .inputItems(springSmall, VanadiumGallium) .inputItems(spring, YttriumBariumCuprate) .inputFluids(Lubricant.getFluid(2000)) - .outputItems(ADJUSTABLE_TRANSFORMER[ZPM]) + .outputItems(POWER_TRANSFORMER[ZPM]) .duration(200).EUt(VA[ZPM]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(TRANSFORMER[UV]) + ASSEMBLER_RECIPES.recipeBuilder("uv_power_transformer") + .inputItems(HI_AMP_TRANSFORMER_4A[UV]) .inputItems(ELECTRIC_PUMP_IV) - .inputItems(wireGtQuadruple, Europium) - .inputItems(wireGtOctal, YttriumBariumCuprate) + .inputItems(cableGtOctal, Europium) + .inputItems(cableGtHex, YttriumBariumCuprate, 2) .inputItems(springSmall, YttriumBariumCuprate) .inputItems(spring, Europium) .inputFluids(Lubricant.getFluid(2000)) - .outputItems(ADJUSTABLE_TRANSFORMER[UV]) + .outputItems(POWER_TRANSFORMER[UV]) .duration(200).EUt(VA[UV]).save(provider); -*/ // 4A Energy Hatches @@ -510,52 +507,50 @@ public static void init(Consumer provider) { .duration(100).EUt(VA[UV]).save(provider); // 16A Dynamo Hatches - // TODO Adjustable transformers -/* - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(ADJUSTABLE_TRANSFORMER[IV]) - .inputItems(ENERGY_OUTPUT_HATCH_4A[1]) + + ASSEMBLER_RECIPES.recipeBuilder("dynamo_hatch_16a_ev") + .inputItems(HI_AMP_TRANSFORMER_4A[IV]) + .inputItems(ENERGY_OUTPUT_HATCH_4A[IV]) .inputItems(HIGH_POWER_INTEGRATED_CIRCUIT, 2) .inputItems(VOLTAGE_COIL_IV) .inputItems(wireGtOctal, Tungsten, 2) - .outputItems(ENERGY_OUTPUT_HATCH_16A[0]) + .outputItems(ENERGY_OUTPUT_HATCH_16A[EV]) .duration(200).EUt(VA[EV]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(ADJUSTABLE_TRANSFORMER[LuV]) - .inputItems(ENERGY_OUTPUT_HATCH_4A[2]) + ASSEMBLER_RECIPES.recipeBuilder("dynamo_hatch_16a_iv") + .inputItems(HI_AMP_TRANSFORMER_4A[LuV]) + .inputItems(ENERGY_OUTPUT_HATCH_4A[LuV]) .inputItems(HIGH_POWER_INTEGRATED_CIRCUIT, 2) .inputItems(VOLTAGE_COIL_LuV) .inputItems(wireGtOctal, NiobiumTitanium, 2) - .outputItems(ENERGY_OUTPUT_HATCH_16A[1]) + .outputItems(ENERGY_OUTPUT_HATCH_16A[IV]) .duration(200).EUt(VA[IV]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(ADJUSTABLE_TRANSFORMER[ZPM]) - .inputItems(ENERGY_OUTPUT_HATCH_4A[3]) + ASSEMBLER_RECIPES.recipeBuilder("dynamo_hatch_16a_luv") + .inputItems(HI_AMP_TRANSFORMER_4A[ZPM]) + .inputItems(ENERGY_OUTPUT_HATCH_4A[ZPM]) .inputItems(ULTRA_HIGH_POWER_INTEGRATED_CIRCUIT, 2) .inputItems(VOLTAGE_COIL_ZPM) .inputItems(wireGtOctal, VanadiumGallium, 2) - .outputItems(ENERGY_OUTPUT_HATCH_16A[2]) + .outputItems(ENERGY_OUTPUT_HATCH_16A[LuV]) .duration(200).EUt(VA[LuV]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(ADJUSTABLE_TRANSFORMER[UV]) - .inputItems(ENERGY_OUTPUT_HATCH_4A[4]) + ASSEMBLER_RECIPES.recipeBuilder("dynamo_hatch_16a_zpm") + .inputItems(HI_AMP_TRANSFORMER_4A[UV]) + .inputItems(ENERGY_OUTPUT_HATCH_4A[UV]) .inputItems(ULTRA_HIGH_POWER_INTEGRATED_CIRCUIT, 2) .inputItems(VOLTAGE_COIL_UV) .inputItems(wireGtOctal, YttriumBariumCuprate, 2) - .outputItems(ENERGY_OUTPUT_HATCH_16A[3]) + .outputItems(ENERGY_OUTPUT_HATCH_16A[ZPM]) .duration(200).EUt(VA[ZPM]).save(provider); - ASSEMBLER_RECIPES.recipeBuilder() - .inputItems(ENERGY_OUTPUT_HATCH_4A[5], 2) + ASSEMBLER_RECIPES.recipeBuilder("dynamo_hatch_16a_uv") + .inputItems(ENERGY_OUTPUT_HATCH_4A[UHV], 2) .inputItems(ULTRA_HIGH_POWER_INTEGRATED_CIRCUIT, 2) .inputItems(wireGtDouble, RutheniumTriniumAmericiumNeutronate) .inputItems(wireGtOctal, Europium, 2) - .outputItems(ENERGY_OUTPUT_HATCH_16A[4]) + .outputItems(ENERGY_OUTPUT_HATCH_16A[UV]) .duration(200).EUt(VA[UV]).save(provider); - */ // Maintenance Hatch @@ -604,7 +599,6 @@ public static void init(Consumer provider) { .duration(400).EUt(VA[LuV]).save(provider); // Multiblock Fluid Drills - // TODO Multiblock fluid rigs ASSEMBLER_RECIPES.recipeBuilder("mv_fluid_drilling_rig") .inputItems(HULL[MV]) @@ -679,4 +673,254 @@ public static void init(Consumer provider) { .save(provider); } + + // TODO clean this up with a CraftingComponent rework + private static void registerLaserRecipes(Consumer provider) { + + // 256A Laser Target Hatches + ASSEMBLER_RECIPES.recipeBuilder("iv_256a_laser_target_hatch") + .inputItems(HULL[IV]) + .inputItems(lens, Diamond) + .inputItems(EMITTER_IV) + .inputItems(ELECTRIC_PUMP_IV) + .inputItems(cableGtSingle, Platinum, 4) + .circuitMeta(1) + .outputItems(LASER_INPUT_HATCH_256[IV]) + .duration(300).EUt(VA[IV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("luv_256a_laser_target_hatch") + .inputItems(HULL[LuV]) + .inputItems(lens, Diamond) + .inputItems(EMITTER_LuV) + .inputItems(ELECTRIC_PUMP_LuV) + .inputItems(cableGtSingle, NiobiumTitanium, 4) + .circuitMeta(1) + .outputItems(LASER_INPUT_HATCH_256[LuV]) + .duration(300).EUt(VA[LuV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("zpm_256a_laser_target_hatch") + .inputItems(HULL[ZPM]) + .inputItems(lens, Diamond) + .inputItems(EMITTER_ZPM) + .inputItems(ELECTRIC_PUMP_ZPM) + .inputItems(cableGtSingle, VanadiumGallium, 4) + .circuitMeta(1) + .outputItems(LASER_INPUT_HATCH_256[ZPM]) + .duration(300).EUt(VA[ZPM]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("uv_256a_laser_target_hatch") + .inputItems(HULL[UV]) + .inputItems(lens, Diamond) + .inputItems(EMITTER_UV) + .inputItems(ELECTRIC_PUMP_UV) + .inputItems(cableGtSingle, YttriumBariumCuprate, 4) + .circuitMeta(1) + .outputItems(LASER_INPUT_HATCH_256[UV]) + .duration(300).EUt(VA[UV]).save(provider); + + // 256A Laser Source Hatches + ASSEMBLER_RECIPES.recipeBuilder("iv_256a_laser_source_hatch") + .inputItems(HULL[IV]) + .inputItems(lens, Diamond) + .inputItems(SENSOR_IV) + .inputItems(ELECTRIC_PUMP_IV) + .inputItems(cableGtSingle, Platinum, 4) + .circuitMeta(1) + .outputItems(LASER_OUTPUT_HATCH_256[IV]) + .duration(300).EUt(VA[IV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("luv_256a_laser_source_hatch") + .inputItems(HULL[LuV]) + .inputItems(lens, Diamond) + .inputItems(SENSOR_LuV) + .inputItems(ELECTRIC_PUMP_LuV) + .inputItems(cableGtSingle, NiobiumTitanium, 4) + .circuitMeta(1) + .outputItems(LASER_OUTPUT_HATCH_256[LuV]) + .duration(300).EUt(VA[LuV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("zpm_256a_laser_source_hatch") + .inputItems(HULL[ZPM]) + .inputItems(lens, Diamond) + .inputItems(SENSOR_ZPM) + .inputItems(ELECTRIC_PUMP_ZPM) + .inputItems(cableGtSingle, VanadiumGallium, 4) + .circuitMeta(1) + .outputItems(LASER_OUTPUT_HATCH_256[ZPM]) + .duration(300).EUt(VA[ZPM]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("uv_256a_laser_source_hatch") + .inputItems(HULL[UV]) + .inputItems(lens, Diamond) + .inputItems(SENSOR_UV) + .inputItems(ELECTRIC_PUMP_UV) + .inputItems(cableGtSingle, YttriumBariumCuprate, 4) + .circuitMeta(1) + .outputItems(LASER_OUTPUT_HATCH_256[UV]) + .duration(300).EUt(VA[UV]).save(provider); + + // 1024A Laser Target Hatches + ASSEMBLER_RECIPES.recipeBuilder("iv_1024a_laser_target_hatch") + .inputItems(HULL[IV]) + .inputItems(lens, Diamond, 2) + .inputItems(EMITTER_IV, 2) + .inputItems(ELECTRIC_PUMP_IV, 2) + .inputItems(cableGtDouble, Platinum, 4) + .circuitMeta(2) + .outputItems(LASER_INPUT_HATCH_1024[IV]) + .duration(600).EUt(VA[IV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("luv_1024a_laser_target_hatch") + .inputItems(HULL[LuV]) + .inputItems(lens, Diamond, 2) + .inputItems(EMITTER_LuV, 2) + .inputItems(ELECTRIC_PUMP_LuV, 2) + .inputItems(cableGtDouble, NiobiumTitanium, 4) + .circuitMeta(2) + .outputItems(LASER_INPUT_HATCH_1024[LuV]) + .duration(600).EUt(VA[LuV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("zpm_1024a_laser_target_hatch") + .inputItems(HULL[ZPM]) + .inputItems(lens, Diamond, 2) + .inputItems(EMITTER_ZPM, 2) + .inputItems(ELECTRIC_PUMP_ZPM, 2) + .inputItems(cableGtDouble, VanadiumGallium, 4) + .circuitMeta(2) + .outputItems(LASER_INPUT_HATCH_1024[ZPM]) + .duration(600).EUt(VA[ZPM]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("uv_1024a_laser_target_hatch") + .inputItems(HULL[UV]) + .inputItems(lens, Diamond, 2) + .inputItems(EMITTER_UV, 2) + .inputItems(ELECTRIC_PUMP_UV, 2) + .inputItems(cableGtDouble, YttriumBariumCuprate, 4) + .circuitMeta(2) + .outputItems(LASER_INPUT_HATCH_1024[UV]) + .duration(600).EUt(VA[UV]).save(provider); + + // 1024A Laser Source Hatches + ASSEMBLER_RECIPES.recipeBuilder("iv_1024a_laser_source_hatch") + .inputItems(HULL[IV]) + .inputItems(lens, Diamond, 2) + .inputItems(SENSOR_IV, 2) + .inputItems(ELECTRIC_PUMP_IV, 2) + .inputItems(cableGtDouble, Platinum, 4) + .circuitMeta(2) + .outputItems(LASER_OUTPUT_HATCH_1024[IV]) + .duration(600).EUt(VA[IV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("luv_1024a_laser_source_hatch") + .inputItems(HULL[LuV]) + .inputItems(lens, Diamond, 2) + .inputItems(SENSOR_LuV, 2) + .inputItems(ELECTRIC_PUMP_LuV, 2) + .inputItems(cableGtDouble, NiobiumTitanium, 4) + .circuitMeta(2) + .outputItems(LASER_OUTPUT_HATCH_1024[LuV]) + .duration(600).EUt(VA[LuV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("zpm_1024a_laser_source_hatch") + .inputItems(HULL[ZPM]) + .inputItems(lens, Diamond, 2) + .inputItems(SENSOR_ZPM, 2) + .inputItems(ELECTRIC_PUMP_ZPM, 2) + .inputItems(cableGtDouble, VanadiumGallium, 4) + .circuitMeta(2) + .outputItems(LASER_OUTPUT_HATCH_1024[ZPM]) + .duration(600).EUt(VA[ZPM]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("uv_1024a_laser_source_hatch") + .inputItems(HULL[UV]) + .inputItems(lens, Diamond, 2) + .inputItems(SENSOR_UV, 2) + .inputItems(ELECTRIC_PUMP_UV, 2) + .inputItems(cableGtDouble, YttriumBariumCuprate, 4) + .circuitMeta(2) + .outputItems(LASER_OUTPUT_HATCH_1024[UV]) + .duration(600).EUt(VA[UV]).save(provider); + + // 4096A Laser Target Hatches + ASSEMBLER_RECIPES.recipeBuilder("iv_4096a_laser_target_hatch") + .inputItems(HULL[IV]) + .inputItems(lens, Diamond, 4) + .inputItems(EMITTER_IV, 4) + .inputItems(ELECTRIC_PUMP_IV, 4) + .inputItems(cableGtQuadruple, Platinum, 4) + .circuitMeta(3) + .outputItems(LASER_INPUT_HATCH_4096[IV]) + .duration(1200).EUt(VA[IV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("luv_4096a_laser_target_hatch") + .inputItems(HULL[LuV]) + .inputItems(lens, Diamond, 4) + .inputItems(EMITTER_LuV, 4) + .inputItems(ELECTRIC_PUMP_LuV, 4) + .inputItems(cableGtQuadruple, NiobiumTitanium, 4) + .circuitMeta(3) + .outputItems(LASER_INPUT_HATCH_4096[LuV]) + .duration(1200).EUt(VA[LuV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("zpm_4096a_laser_target_hatch") + .inputItems(HULL[ZPM]) + .inputItems(lens, Diamond, 4) + .inputItems(EMITTER_ZPM, 4) + .inputItems(ELECTRIC_PUMP_ZPM, 4) + .inputItems(cableGtQuadruple, VanadiumGallium, 4) + .circuitMeta(3) + .outputItems(LASER_INPUT_HATCH_4096[ZPM]) + .duration(1200).EUt(VA[ZPM]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("uv_4096a_laser_target_hatch") + .inputItems(HULL[UV]) + .inputItems(lens, Diamond, 4) + .inputItems(EMITTER_UV, 4) + .inputItems(ELECTRIC_PUMP_UV, 4) + .inputItems(cableGtQuadruple, YttriumBariumCuprate, 4) + .circuitMeta(3) + .outputItems(LASER_INPUT_HATCH_4096[UV]) + .duration(1200).EUt(VA[UV]).save(provider); + + // 4096A Laser Source Hatches + ASSEMBLER_RECIPES.recipeBuilder("iv_4096a_laser_source_hatch") + .inputItems(HULL[IV]) + .inputItems(lens, Diamond, 4) + .inputItems(SENSOR_IV, 4) + .inputItems(ELECTRIC_PUMP_IV, 4) + .inputItems(cableGtQuadruple, Platinum, 4) + .circuitMeta(3) + .outputItems(LASER_OUTPUT_HATCH_4096[IV]) + .duration(1200).EUt(VA[IV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("luv_4096a_laser_source_hatch") + .inputItems(HULL[LuV]) + .inputItems(lens, Diamond, 4) + .inputItems(SENSOR_LuV, 4) + .inputItems(ELECTRIC_PUMP_LuV, 4) + .inputItems(cableGtQuadruple, NiobiumTitanium, 4) + .circuitMeta(3) + .outputItems(LASER_OUTPUT_HATCH_4096[LuV]) + .duration(1200).EUt(VA[LuV]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("zpm_4096a_laser_source_hatch") + .inputItems(HULL[ZPM]) + .inputItems(lens, Diamond, 4) + .inputItems(SENSOR_ZPM, 4) + .inputItems(ELECTRIC_PUMP_ZPM, 4) + .inputItems(cableGtQuadruple, VanadiumGallium, 4) + .circuitMeta(3) + .outputItems(LASER_OUTPUT_HATCH_4096[ZPM]) + .duration(1200).EUt(VA[ZPM]).save(provider); + + ASSEMBLER_RECIPES.recipeBuilder("uv_4096a_laser_source_hatch") + .inputItems(HULL[UV]) + .inputItems(lens, Diamond, 4) + .inputItems(SENSOR_UV, 4) + .inputItems(ELECTRIC_PUMP_UV, 4) + .inputItems(cableGtQuadruple, YttriumBariumCuprate, 4) + .circuitMeta(3) + .outputItems(LASER_OUTPUT_HATCH_4096[UV]) + .duration(1200).EUt(VA[UV]).save(provider); + } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/jade/provider/ElectricContainerBlockProvider.java b/common/src/main/java/com/gregtechceu/gtceu/integration/jade/provider/ElectricContainerBlockProvider.java index ba173afa14..f150976c4b 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/jade/provider/ElectricContainerBlockProvider.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/jade/provider/ElectricContainerBlockProvider.java @@ -53,4 +53,9 @@ protected void addTooltip(CompoundTag capData, ITooltip tooltip, Player player, ) ); } + + @Override + protected boolean allowDisplaying(IEnergyContainer capability) { + return !capability.isOneProbeHidden(); + } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java index a358ead3af..7dd8a448a0 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java @@ -20,7 +20,6 @@ import com.gregtechceu.gtceu.integration.kjs.recipe.components.CapabilityMap; import com.gregtechceu.gtceu.integration.kjs.recipe.components.GTRecipeComponents; import com.lowdragmc.lowdraglib.LDLib; -import com.lowdragmc.lowdraglib.side.fluid.FluidStack; import dev.latvian.mods.kubejs.fluid.FluidStackJS; import dev.latvian.mods.kubejs.fluid.InputFluid; import dev.latvian.mods.kubejs.item.InputItem; @@ -108,8 +107,7 @@ public GTRecipeJS addCondition(RecipeCondition condition) { } public GTRecipeJS inputEU(long eu) { - input(EURecipeCapability.CAP, eu); - return this; + return input(EURecipeCapability.CAP, eu); } public GTRecipeJS EUt(long eu) { @@ -128,10 +126,6 @@ public GTRecipeJS outputEU(long eu) { return output(EURecipeCapability.CAP, eu); } - public GTRecipeJS itemInputs(InputItem... inputs) { - return inputItems(inputs); - } - public GTRecipeJS itemInput(UnificationEntry input) { return inputItems(input); } @@ -158,10 +152,6 @@ public GTRecipeJS inputItems(TagKey tag, int amount) { return inputItems(InputItem.of(SizedIngredient.create(tag, amount))); } - public GTRecipeJS inputItems(TagKey tag) { - return inputItems(tag, 1); - } - public GTRecipeJS inputItems(Item input, int amount) { return inputItems(new ItemStack(input, amount)); } diff --git a/common/src/main/resources/assets/gtceu/models/block/machine/part/laser_hatch.source.json b/common/src/main/resources/assets/gtceu/models/block/machine/part/laser_hatch.source.json new file mode 100644 index 0000000000..8d45d3ea12 --- /dev/null +++ b/common/src/main/resources/assets/gtceu/models/block/machine/part/laser_hatch.source.json @@ -0,0 +1,16 @@ +{ + "credit": "Made with Blockbench", + "parent": "block/block", + "textures": { + "overlay_hatch": "gtceu:block/overlay/machine/overlay_laser_source" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 0], + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#overlay_hatch", "cullface": "north", "tintindex": 2 } + } + } + ] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/gtceu/models/block/machine/part/laser_hatch.target.json b/common/src/main/resources/assets/gtceu/models/block/machine/part/laser_hatch.target.json new file mode 100644 index 0000000000..225780038c --- /dev/null +++ b/common/src/main/resources/assets/gtceu/models/block/machine/part/laser_hatch.target.json @@ -0,0 +1,16 @@ +{ + "credit": "Made with Blockbench", + "parent": "block/block", + "textures": { + "overlay_hatch": "gtceu:block/overlay/machine/overlay_laser_target" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 0], + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#overlay_hatch", "cullface": "north", "tintindex": 2 } + } + } + ] +} \ No newline at end of file diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/back.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/back.png new file mode 100644 index 0000000000..716ac0256d Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/back.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/bottom.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/bottom.png new file mode 100644 index 0000000000..a8a7bddf0a Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/bottom.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/front.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/front.png new file mode 100644 index 0000000000..716ac0256d Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/front.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/side.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/side.png new file mode 100644 index 0000000000..716ac0256d Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/side.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/top.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/top.png new file mode 100644 index 0000000000..a8a7bddf0a Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/advanced_computer_casing/top.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/back.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/back.png new file mode 100644 index 0000000000..46997fa276 Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/back.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/bottom.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/bottom.png new file mode 100644 index 0000000000..00a1020fec Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/bottom.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/front.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/front.png new file mode 100644 index 0000000000..46997fa276 Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/front.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/side.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/side.png new file mode 100644 index 0000000000..46997fa276 Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/side.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/top.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/top.png new file mode 100644 index 0000000000..00a1020fec Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_casing/top.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_heat_vent_side.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_heat_vent_side.png new file mode 100644 index 0000000000..7ca5c68e8f Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_heat_vent_side.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_heat_vent_top_bot.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_heat_vent_top_bot.png new file mode 100644 index 0000000000..25dc8bba1d Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/computer_heat_vent_top_bot.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/damaged_advanced_hpca_component_side.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/damaged_advanced_hpca_component_side.png new file mode 100644 index 0000000000..104a31277f Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/damaged_advanced_hpca_component_side.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/damaged_hpca_component_side.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/damaged_hpca_component_side.png new file mode 100644 index 0000000000..a267815e26 Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/damaged_hpca_component_side.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/high_power_casing.png b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/high_power_casing.png new file mode 100644 index 0000000000..25f9a1364f Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/casings/hpca/high_power_casing.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front.png b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front.png new file mode 100644 index 0000000000..4f3293e6fc Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front.png.mcmeta b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front.png.mcmeta new file mode 100644 index 0000000000..3de4a0bdd8 --- /dev/null +++ b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 8 + } +} diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active.png b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active.png new file mode 100644 index 0000000000..1cef08aaaa Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active.png.mcmeta b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active.png.mcmeta new file mode 100644 index 0000000000..3de4a0bdd8 --- /dev/null +++ b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 8 + } +} diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active_emissive.png b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active_emissive.png new file mode 100644 index 0000000000..0fb7b97559 Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active_emissive.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active_emissive.png.mcmeta b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active_emissive.png.mcmeta new file mode 100644 index 0000000000..3de4a0bdd8 --- /dev/null +++ b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_active_emissive.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 8 + } +} diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_emissive.png b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_emissive.png new file mode 100644 index 0000000000..731aec4530 Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_emissive.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_emissive.png.mcmeta b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_emissive.png.mcmeta new file mode 100644 index 0000000000..3de4a0bdd8 --- /dev/null +++ b/common/src/main/resources/assets/gtceu/textures/block/multiblock/data_bank/overlay_front_emissive.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 8 + } +} diff --git a/common/src/main/resources/assets/gtceu/textures/block/overlay/machine/overlay_laser_source.png b/common/src/main/resources/assets/gtceu/textures/block/overlay/machine/overlay_laser_source.png new file mode 100644 index 0000000000..4706e3cf6a Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/overlay/machine/overlay_laser_source.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/overlay/machine/overlay_laser_target.png b/common/src/main/resources/assets/gtceu/textures/block/overlay/machine/overlay_laser_target.png new file mode 100644 index 0000000000..51f387ba35 Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/overlay/machine/overlay_laser_target.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_in.png b/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_in.png new file mode 100644 index 0000000000..d6fadda23b Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_in.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_side.png b/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_side.png new file mode 100644 index 0000000000..4cc80633b7 Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_side.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_side_overlay.png b/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_side_overlay.png new file mode 100644 index 0000000000..80f9097813 Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_side_overlay.png differ diff --git a/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_side_overlay_emissive.png b/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_side_overlay_emissive.png new file mode 100644 index 0000000000..cc87a2b9bd Binary files /dev/null and b/common/src/main/resources/assets/gtceu/textures/block/pipe/pipe_laser_side_overlay_emissive.png differ diff --git a/fabric/src/main/java/com/gregtechceu/gtceu/api/blockentity/fabric/MetaMachineBlockEntityImpl.java b/fabric/src/main/java/com/gregtechceu/gtceu/api/blockentity/fabric/MetaMachineBlockEntityImpl.java index 8b87040fcf..df236fadda 100644 --- a/fabric/src/main/java/com/gregtechceu/gtceu/api/blockentity/fabric/MetaMachineBlockEntityImpl.java +++ b/fabric/src/main/java/com/gregtechceu/gtceu/api/blockentity/fabric/MetaMachineBlockEntityImpl.java @@ -10,6 +10,7 @@ import com.gregtechceu.gtceu.api.machine.trait.MachineTrait; import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.misc.EnergyContainerList; +import com.gregtechceu.gtceu.api.misc.LaserContainerList; import com.gregtechceu.gtceu.api.pipenet.longdistance.ILDEndpoint; import com.gregtechceu.gtceu.common.pipelike.fluidpipe.longdistance.LDFluidEndpointMachine; import com.gregtechceu.gtceu.common.pipelike.item.longdistance.LDItemEndpointMachine; @@ -122,6 +123,13 @@ public static void onBlockEntityRegister(BlockEntityType type) { var transfer = ((IMachineBlockEntity)blockEntity).getMetaMachine().getFluidTransferCap(side); return transfer == null ? null : FluidTransferHelperImpl.toFluidVariantStorage(transfer); }, type); + GTCapability.CAPABILITY_LASER.registerForBlockEntity((blockEntity, side) -> { + if (((IMachineBlockEntity)blockEntity).getMetaMachine() instanceof ILaserContainer energyContainer) { + return energyContainer; + } + var list = ((IMachineBlockEntity)blockEntity).getMetaMachine().getTraits().stream().filter(ILaserContainer.class::isInstance).filter(t -> t.hasCapability(side)).map(ILaserContainer.class::cast).toList(); + return list.isEmpty() ? null : list.size() == 1 ? list.get(0) : new LaserContainerList(list); + }, type); if (GTCEu.isRebornEnergyLoaded()) { EnergyStorage.SIDED.registerForBlockEntity((blockEntity, side) -> { if (((IMachineBlockEntity)blockEntity).getMetaMachine() instanceof IPlatformEnergyStorage platformEnergyStorage) { diff --git a/fabric/src/main/java/com/gregtechceu/gtceu/api/capability/fabric/GTCapability.java b/fabric/src/main/java/com/gregtechceu/gtceu/api/capability/fabric/GTCapability.java index 371718d37e..2c050a38e0 100644 --- a/fabric/src/main/java/com/gregtechceu/gtceu/api/capability/fabric/GTCapability.java +++ b/fabric/src/main/java/com/gregtechceu/gtceu/api/capability/fabric/GTCapability.java @@ -41,4 +41,7 @@ public class GTCapability { public static final BlockApiLookup CAPABILITY_MAINTENANCE_MACHINE = BlockApiLookup.get(GTCEu.id("maintenance_machine"), IMaintenanceMachine.class, Direction.class); + + public static final BlockApiLookup CAPABILITY_LASER = + BlockApiLookup.get(GTCEu.id("laser_container"), ILaserContainer.class, Direction.class); } diff --git a/fabric/src/main/java/com/gregtechceu/gtceu/api/capability/fabric/GTCapabilityHelperImpl.java b/fabric/src/main/java/com/gregtechceu/gtceu/api/capability/fabric/GTCapabilityHelperImpl.java index 833d6dd5ac..5c9802c03f 100644 --- a/fabric/src/main/java/com/gregtechceu/gtceu/api/capability/fabric/GTCapabilityHelperImpl.java +++ b/fabric/src/main/java/com/gregtechceu/gtceu/api/capability/fabric/GTCapabilityHelperImpl.java @@ -82,4 +82,9 @@ public static ICleanroomReceiver getCleanroomReceiver(Level level, BlockPos pos, public static IMaintenanceMachine getMaintenanceMachine(Level level, BlockPos pos, @Nullable Direction side) { return GTCapability.CAPABILITY_MAINTENANCE_MACHINE.find(level, pos, side); } + + @Nullable + public static ILaserContainer getLaser(Level level, BlockPos pos, @Nullable Direction side) { + return GTCapability.CAPABILITY_LASER.find(level, pos, side); + } } diff --git a/fabric/src/main/java/com/gregtechceu/gtceu/common/blockentity/fabric/LaserPipeBlockEntityImpl.java b/fabric/src/main/java/com/gregtechceu/gtceu/common/blockentity/fabric/LaserPipeBlockEntityImpl.java new file mode 100644 index 0000000000..e2c520ff07 --- /dev/null +++ b/fabric/src/main/java/com/gregtechceu/gtceu/common/blockentity/fabric/LaserPipeBlockEntityImpl.java @@ -0,0 +1,34 @@ +package com.gregtechceu.gtceu.common.blockentity.fabric; + +import com.gregtechceu.gtceu.api.capability.fabric.GTCapability; +import com.gregtechceu.gtceu.common.blockentity.LaserPipeBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; + +public class LaserPipeBlockEntityImpl extends LaserPipeBlockEntity { + protected LaserPipeBlockEntityImpl(BlockEntityType type, BlockPos pos, BlockState blockState) { + super(type, pos, blockState); + } + + public static LaserPipeBlockEntity create(BlockEntityType type, BlockPos pos, BlockState blockState) { + return new LaserPipeBlockEntityImpl(type, pos, blockState); + } + + public static void onBlockEntityRegister(BlockEntityType type) { + GTCapability.CAPABILITY_LASER.registerForBlockEntity((blockEntity, direction) -> { + Level world = blockEntity.getLevel(); + if (world.isClientSide()) + return blockEntity.clientCapability; + + if (blockEntity.getHandlers().isEmpty()) { + blockEntity.initHandlers(); + } + blockEntity.checkNetwork(); + return blockEntity.getHandlers().getOrDefault(direction, blockEntity.getDefaultHandler()); + }, type); + GTCapability.CAPABILITY_COVERABLE.registerForBlockEntity((blockEntity, direction) -> blockEntity.getCoverContainer(), type); + GTCapability.CAPABILITY_TOOLABLE.registerForBlockEntity((blockEntity, direction) -> blockEntity, type); + } +} diff --git a/forge/src/main/java/com/gregtechceu/gtceu/api/blockentity/forge/MetaMachineBlockEntityImpl.java b/forge/src/main/java/com/gregtechceu/gtceu/api/blockentity/forge/MetaMachineBlockEntityImpl.java index a8954d5f73..8a0fe219ef 100644 --- a/forge/src/main/java/com/gregtechceu/gtceu/api/blockentity/forge/MetaMachineBlockEntityImpl.java +++ b/forge/src/main/java/com/gregtechceu/gtceu/api/blockentity/forge/MetaMachineBlockEntityImpl.java @@ -9,6 +9,7 @@ import com.gregtechceu.gtceu.api.machine.trait.MachineTrait; import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.misc.EnergyContainerList; +import com.gregtechceu.gtceu.api.misc.LaserContainerList; import com.gregtechceu.gtceu.api.pipenet.longdistance.ILDEndpoint; import com.gregtechceu.gtceu.client.renderer.GTRendererProvider; import com.gregtechceu.gtceu.common.pipelike.fluidpipe.longdistance.LDFluidEndpointMachine; @@ -143,6 +144,15 @@ public static LazyOptional getCapability(MetaMachine machine, @NotNull C // TODO wrap list in the future return ForgeCapabilities.ENERGY.orEmpty(cap, LazyOptional.of(() -> GTEnergyHelperImpl.toEnergyStorage(list.get(0)))); } + } else if (cap == GTCapability.CAPABILITY_LASER) { + if (machine instanceof ILaserContainer energyContainer) { + return GTCapability.CAPABILITY_ENERGY_CONTAINER.orEmpty(cap, LazyOptional.of(() -> energyContainer)); + } + var list = machine.getTraits().stream().filter(ILaserContainer.class::isInstance).filter(t -> t.hasCapability(side)).map(ILaserContainer.class::cast).toList(); + if (!list.isEmpty()) { + return GTCapability.CAPABILITY_ENERGY_CONTAINER.orEmpty(cap, LazyOptional.of(() -> list.size() == 1 ? list.get(0) : new LaserContainerList(list))); + } + } return null; } diff --git a/forge/src/main/java/com/gregtechceu/gtceu/api/capability/forge/GTCapability.java b/forge/src/main/java/com/gregtechceu/gtceu/api/capability/forge/GTCapability.java index 69cb1155d3..3ceb238695 100644 --- a/forge/src/main/java/com/gregtechceu/gtceu/api/capability/forge/GTCapability.java +++ b/forge/src/main/java/com/gregtechceu/gtceu/api/capability/forge/GTCapability.java @@ -23,6 +23,7 @@ public class GTCapability { public static final Capability CAPABILITY_ELECTRIC_ITEM = CapabilityManager.get(new CapabilityToken<>() {}); public static final Capability CAPABILITY_CLEANROOM_RECEIVER = CapabilityManager.get(new CapabilityToken<>() {}); public static final Capability CAPABILITY_MAINTENANCE_MACHINE = CapabilityManager.get(new CapabilityToken<>() {}); + public static final Capability CAPABILITY_LASER = CapabilityManager.get(new CapabilityToken<>() {}); public static void register(RegisterCapabilitiesEvent event) { event.register(IEnergyContainer.class); diff --git a/forge/src/main/java/com/gregtechceu/gtceu/api/capability/forge/GTCapabilityHelperImpl.java b/forge/src/main/java/com/gregtechceu/gtceu/api/capability/forge/GTCapabilityHelperImpl.java index b4103d55f5..e01c421045 100644 --- a/forge/src/main/java/com/gregtechceu/gtceu/api/capability/forge/GTCapabilityHelperImpl.java +++ b/forge/src/main/java/com/gregtechceu/gtceu/api/capability/forge/GTCapabilityHelperImpl.java @@ -129,4 +129,15 @@ public static IMaintenanceMachine getMaintenanceMachine(Level level, BlockPos po } return null; } + + @Nullable + public static ILaserContainer getLaser(Level level, BlockPos pos, @Nullable Direction side) { + if (level.getBlockState(pos).hasBlockEntity()) { + var blockEntity = level.getBlockEntity(pos); + if (blockEntity != null) { + return blockEntity.getCapability(GTCapability.CAPABILITY_LASER, side).resolve().orElse(null); + } + } + return null; + } } diff --git a/forge/src/main/java/com/gregtechceu/gtceu/common/blockentity/forge/LaserPipeBlockEntityImpl.java b/forge/src/main/java/com/gregtechceu/gtceu/common/blockentity/forge/LaserPipeBlockEntityImpl.java new file mode 100644 index 0000000000..3c4a5b7ce9 --- /dev/null +++ b/forge/src/main/java/com/gregtechceu/gtceu/common/blockentity/forge/LaserPipeBlockEntityImpl.java @@ -0,0 +1,45 @@ +package com.gregtechceu.gtceu.common.blockentity.forge; + +import com.gregtechceu.gtceu.api.capability.forge.GTCapability; +import com.gregtechceu.gtceu.common.blockentity.LaserPipeBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class LaserPipeBlockEntityImpl extends LaserPipeBlockEntity { + protected LaserPipeBlockEntityImpl(BlockEntityType type, BlockPos pos, BlockState blockState) { + super(type, pos, blockState); + } + + public static LaserPipeBlockEntity create(BlockEntityType type, BlockPos pos, BlockState blockState) { + return new LaserPipeBlockEntityImpl(type, pos, blockState); + } + + @Override + public @NotNull LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction side) { + if (cap == GTCapability.CAPABILITY_LASER) { + if (getLevel().isClientSide()) + return GTCapability.CAPABILITY_LASER.orEmpty(cap, LazyOptional.of(() -> clientCapability)); + + if (handlers.isEmpty()) { + initHandlers(); + } + checkNetwork(); + return GTCapability.CAPABILITY_LASER.orEmpty(cap, LazyOptional.of(() -> handlers.getOrDefault(side, defaultHandler))); + } else if (cap == GTCapability.CAPABILITY_COVERABLE) { + return GTCapability.CAPABILITY_COVERABLE.orEmpty(cap, LazyOptional.of(this::getCoverContainer)); + } else if (cap == GTCapability.CAPABILITY_TOOLABLE) { + return GTCapability.CAPABILITY_TOOLABLE.orEmpty(cap, LazyOptional.of(() -> this)); + } + return super.getCapability(cap, side); + } + + public static void onBlockEntityRegister(BlockEntityType cableBlockEntityBlockEntityType) { + + } +}