mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-14 00:43:47 +01:00
Compilation dependency toggle
This commit is contained in:
parent
b2cd60b619
commit
374848f978
22 changed files with 191 additions and 82 deletions
|
@ -170,8 +170,10 @@ dependencies {
|
|||
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_minecraft_version}-${curios_version}:api")
|
||||
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_minecraft_version}-${curios_version}")
|
||||
|
||||
if (cc_tweaked_enable.toBoolean()) {
|
||||
compileOnly fg.deobf("org.squiddev:cc-tweaked-${cc_tweaked_minecraft_version}:${cc_tweaked_version}:api")
|
||||
runtimeOnly fg.deobf("org.squiddev:cc-tweaked-${cc_tweaked_minecraft_version}:${cc_tweaked_version}")
|
||||
}
|
||||
|
||||
// implementation fg.deobf("curse.maven:druidcraft-340991:3101903")
|
||||
// implementation fg.deobf("com.ferreusveritas.dynamictrees:DynamicTrees-1.16.5:0.10.0-Beta25")
|
||||
|
@ -189,6 +191,12 @@ dependencies {
|
|||
}
|
||||
}
|
||||
|
||||
sourceSets.main.java {
|
||||
if (!cc_tweaked_enable.toBoolean()) {
|
||||
exclude 'com/simibubi/create/compat/computercraft/implementation/**'
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.main.resources {
|
||||
srcDir 'src/generated/resources'
|
||||
exclude '.cache/'
|
||||
|
|
|
@ -26,6 +26,8 @@ jei_minecraft_version = 1.18.2
|
|||
jei_version = 9.7.0.209
|
||||
curios_minecraft_version = 1.18.2
|
||||
curios_version = 5.0.7.0
|
||||
|
||||
cc_tweaked_enable = true
|
||||
cc_tweaked_minecraft_version = 1.18.2
|
||||
cc_tweaked_version = 1.100.10
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.GsonBuilder;
|
||||
import com.simibubi.create.api.behaviour.BlockSpoutingBehaviour;
|
||||
import com.simibubi.create.compat.Mods;
|
||||
import com.simibubi.create.compat.computercraft.ComputerCraftProxy;
|
||||
import com.simibubi.create.compat.curios.Curios;
|
||||
import com.simibubi.create.content.CreateItemGroup;
|
||||
import com.simibubi.create.content.contraptions.TorquePropagator;
|
||||
|
@ -126,6 +127,7 @@ public class Create {
|
|||
ContraptionMovementSetting.registerDefaults();
|
||||
AllArmInteractionPointTypes.register();
|
||||
BlockSpoutingBehaviour.registerDefaults();
|
||||
ComputerCraftProxy.register();
|
||||
|
||||
ForgeMod.enableMilkFluid();
|
||||
CopperRegistries.inject();
|
||||
|
|
|
@ -1,52 +1,24 @@
|
|||
package com.simibubi.create.compat.computercraft;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.common.capabilities.CapabilityToken;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.common.util.NonNullSupplier;
|
||||
|
||||
public class ComputerBehaviour extends TileEntityBehaviour {
|
||||
public class AbstractComputerBehaviour extends TileEntityBehaviour {
|
||||
|
||||
public static final BehaviourType<ComputerBehaviour> TYPE = new BehaviourType<>();
|
||||
protected static final Capability<IPeripheral> PERIPHERAL_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {});
|
||||
|
||||
LazyOptional<IPeripheral> peripheral;
|
||||
NonNullSupplier<IPeripheral> peripheralSupplier;
|
||||
public static final BehaviourType<AbstractComputerBehaviour> TYPE = new BehaviourType<>();
|
||||
|
||||
boolean hasAttachedComputer;
|
||||
|
||||
public ComputerBehaviour(SmartTileEntity te, NonNullSupplier<IPeripheral> peripheralSupplier) {
|
||||
public AbstractComputerBehaviour(SmartTileEntity te) {
|
||||
super(te);
|
||||
this.peripheralSupplier = peripheralSupplier;
|
||||
this.hasAttachedComputer = false;
|
||||
}
|
||||
|
||||
public static <T> boolean isPeripheralCap(@NotNull Capability<T> cap) {
|
||||
return cap == PERIPHERAL_CAPABILITY;
|
||||
}
|
||||
|
||||
public <T> LazyOptional<T> getPeripheralCapability() {
|
||||
if (peripheral == null || !peripheral.isPresent())
|
||||
peripheral = LazyOptional.of(peripheralSupplier);
|
||||
|
||||
return peripheral.cast();
|
||||
}
|
||||
|
||||
public void removePeripheral() {
|
||||
if (peripheral != null) {
|
||||
peripheral.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundTag nbt, boolean clientPacket) {
|
||||
hasAttachedComputer = nbt.getBoolean("HasAttachedComputer");
|
||||
|
@ -59,6 +31,16 @@ public class ComputerBehaviour extends TileEntityBehaviour {
|
|||
super.write(nbt, clientPacket);
|
||||
}
|
||||
|
||||
public <T> boolean isPeripheralCap(Capability<T> cap) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public <T> LazyOptional<T> getPeripheralCapability() {
|
||||
return LazyOptional.empty();
|
||||
}
|
||||
|
||||
public void removePeripheral() {}
|
||||
|
||||
public void setHasAttachedComputer(boolean hasAttachedComputer) {
|
||||
this.hasAttachedComputer = hasAttachedComputer;
|
||||
}
|
|
@ -29,7 +29,8 @@ public class AttachedComputerPacket extends TileEntityDataPacket<SyncedTileEntit
|
|||
@Override
|
||||
protected void handlePacket(SyncedTileEntity tile) {
|
||||
if (tile instanceof SmartTileEntity smartTile) {
|
||||
smartTile.getBehaviour(ComputerBehaviour.TYPE).setHasAttachedComputer(hasAttachedComputer);
|
||||
smartTile.getBehaviour(AbstractComputerBehaviour.TYPE)
|
||||
.setHasAttachedComputer(hasAttachedComputer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.simibubi.create.compat.computercraft;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.simibubi.create.compat.Mods;
|
||||
import com.simibubi.create.compat.computercraft.implementation.ComputerBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
|
||||
public class ComputerCraftProxy {
|
||||
|
||||
public static void register() {
|
||||
fallbackFactory = FallbackComputerBehaviour::new;
|
||||
Mods.COMPUTERCRAFT.executeIfInstalled(() -> ComputerCraftProxy::registerWithDependency);
|
||||
}
|
||||
|
||||
private static void registerWithDependency() {
|
||||
/* Comment if computercraft.implementation is not in the source set */
|
||||
computerFactory = ComputerBehaviour::new;
|
||||
}
|
||||
|
||||
private static Function<SmartTileEntity, ? extends AbstractComputerBehaviour> fallbackFactory;
|
||||
private static Function<SmartTileEntity, ? extends AbstractComputerBehaviour> computerFactory;
|
||||
|
||||
public static AbstractComputerBehaviour behaviour(SmartTileEntity ste) {
|
||||
if (computerFactory == null)
|
||||
return fallbackFactory.apply(ste);
|
||||
return computerFactory.apply(ste);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.simibubi.create.compat.computercraft;
|
||||
|
||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
|
||||
public class FallbackComputerBehaviour extends AbstractComputerBehaviour {
|
||||
|
||||
public FallbackComputerBehaviour(SmartTileEntity te) {
|
||||
super(te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttachedComputer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.simibubi.create.compat.computercraft.implementation;
|
||||
|
||||
import com.simibubi.create.compat.computercraft.AbstractComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.implementation.peripherals.DisplayLinkPeripheral;
|
||||
import com.simibubi.create.compat.computercraft.implementation.peripherals.SequencedGearshiftPeripheral;
|
||||
import com.simibubi.create.compat.computercraft.implementation.peripherals.SpeedControllerPeripheral;
|
||||
import com.simibubi.create.compat.computercraft.implementation.peripherals.SpeedGaugePeripheral;
|
||||
import com.simibubi.create.compat.computercraft.implementation.peripherals.StationPeripheral;
|
||||
import com.simibubi.create.compat.computercraft.implementation.peripherals.StressGaugePeripheral;
|
||||
import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.advanced.sequencer.SequencedGearshiftTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.gauge.SpeedGaugeTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.gauge.StressGaugeTileEntity;
|
||||
import com.simibubi.create.content.logistics.block.display.DisplayLinkTileEntity;
|
||||
import com.simibubi.create.content.logistics.trains.management.edgePoint.station.StationTileEntity;
|
||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.common.capabilities.CapabilityToken;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.common.util.NonNullSupplier;
|
||||
|
||||
public class ComputerBehaviour extends AbstractComputerBehaviour {
|
||||
|
||||
protected static final Capability<IPeripheral> PERIPHERAL_CAPABILITY =
|
||||
CapabilityManager.get(new CapabilityToken<>() {
|
||||
});
|
||||
LazyOptional<IPeripheral> peripheral;
|
||||
NonNullSupplier<IPeripheral> peripheralSupplier;
|
||||
|
||||
public ComputerBehaviour(SmartTileEntity te) {
|
||||
super(te);
|
||||
this.peripheralSupplier = getPeripheralFor(te);
|
||||
}
|
||||
|
||||
public static NonNullSupplier<IPeripheral> getPeripheralFor(SmartTileEntity te) {
|
||||
if (te instanceof SpeedControllerTileEntity scte)
|
||||
return () -> new SpeedControllerPeripheral(scte, scte.targetSpeed);
|
||||
if (te instanceof DisplayLinkTileEntity dlte)
|
||||
return () -> new DisplayLinkPeripheral(dlte);
|
||||
if (te instanceof SequencedGearshiftTileEntity sgte)
|
||||
return () -> new SequencedGearshiftPeripheral(sgte);
|
||||
if (te instanceof SpeedGaugeTileEntity sgte)
|
||||
return () -> new SpeedGaugePeripheral(sgte);
|
||||
if (te instanceof StressGaugeTileEntity sgte)
|
||||
return () -> new StressGaugePeripheral(sgte);
|
||||
if (te instanceof StationTileEntity ste)
|
||||
return () -> new StationPeripheral(ste);
|
||||
|
||||
throw new IllegalArgumentException("No peripheral available for " + te.getType()
|
||||
.getRegistryName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> boolean isPeripheralCap(Capability<T> cap) {
|
||||
return cap == PERIPHERAL_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getPeripheralCapability() {
|
||||
if (peripheral == null || !peripheral.isPresent())
|
||||
peripheral = LazyOptional.of(peripheralSupplier);
|
||||
return peripheral.cast();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePeripheral() {
|
||||
if (peripheral != null)
|
||||
peripheral.invalidate();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.compat.computercraft;
|
||||
package com.simibubi.create.compat.computercraft.implementation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.compat.computercraft.peripherals;
|
||||
package com.simibubi.create.compat.computercraft.implementation.peripherals;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.compat.computercraft.peripherals;
|
||||
package com.simibubi.create.compat.computercraft.implementation.peripherals;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.compat.computercraft.peripherals;
|
||||
package com.simibubi.create.compat.computercraft.implementation.peripherals;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.compat.computercraft.peripherals;
|
||||
package com.simibubi.create.compat.computercraft.implementation.peripherals;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.compat.computercraft.peripherals;
|
||||
package com.simibubi.create.compat.computercraft.implementation.peripherals;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.simibubi.create.compat.computercraft.CreateLuaTable;
|
||||
import com.simibubi.create.compat.computercraft.implementation.CreateLuaTable;
|
||||
import com.simibubi.create.content.logistics.trains.entity.Train;
|
||||
import com.simibubi.create.content.logistics.trains.management.edgePoint.station.GlobalStation;
|
||||
import com.simibubi.create.content.logistics.trains.management.edgePoint.station.StationTileEntity;
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.compat.computercraft.peripherals;
|
||||
package com.simibubi.create.compat.computercraft.implementation.peripherals;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.compat.computercraft.peripherals;
|
||||
package com.simibubi.create.compat.computercraft.implementation.peripherals;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.compat.computercraft.AttachedComputerPacket;
|
||||
import com.simibubi.create.compat.computercraft.ComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.implementation.ComputerBehaviour;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
|
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.compat.computercraft.ComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.peripherals.SpeedControllerPeripheral;
|
||||
import com.simibubi.create.compat.computercraft.AbstractComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.ComputerCraftProxy;
|
||||
import com.simibubi.create.content.contraptions.RotationPropagator;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.motor.CreativeMotorTileEntity;
|
||||
|
@ -31,8 +31,8 @@ import net.minecraftforge.common.util.LazyOptional;
|
|||
public class SpeedControllerTileEntity extends KineticTileEntity {
|
||||
|
||||
public static final int DEFAULT_SPEED = 16;
|
||||
protected ScrollValueBehaviour targetSpeed;
|
||||
ComputerBehaviour computerBehaviour;
|
||||
public ScrollValueBehaviour targetSpeed;
|
||||
public AbstractComputerBehaviour computerBehaviour;
|
||||
|
||||
boolean hasBracket;
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class SpeedControllerTileEntity extends KineticTileEntity {
|
|||
targetSpeed.withCallback(i -> this.updateTargetRotation());
|
||||
targetSpeed.withStepFunction(CreativeMotorTileEntity::step);
|
||||
behaviours.add(targetSpeed);
|
||||
behaviours.add(computerBehaviour = new ComputerBehaviour(this, () -> new SpeedControllerPeripheral(this, targetSpeed)));
|
||||
behaviours.add(computerBehaviour = ComputerCraftProxy.behaviour(this));
|
||||
|
||||
registerAwardables(behaviours, AllAdvancements.SPEED_CONTROLLER);
|
||||
}
|
||||
|
@ -139,9 +139,8 @@ public class SpeedControllerTileEntity extends KineticTileEntity {
|
|||
@NotNull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
|
||||
if (ComputerBehaviour.isPeripheralCap(cap))
|
||||
if (computerBehaviour.isPeripheralCap(cap))
|
||||
return computerBehaviour.getPeripheralCapability();
|
||||
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import java.util.Vector;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.compat.computercraft.ComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.peripherals.SequencedGearshiftPeripheral;
|
||||
import com.simibubi.create.compat.computercraft.AbstractComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.ComputerCraftProxy;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.SplitShaftTileEntity;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity {
|
|||
int timer;
|
||||
boolean poweredPreviously;
|
||||
|
||||
ComputerBehaviour computerBehaviour;
|
||||
public AbstractComputerBehaviour computerBehaviour;
|
||||
|
||||
public SequencedGearshiftTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
|
@ -44,7 +44,7 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity {
|
|||
@Override
|
||||
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
|
||||
super.addBehaviours(behaviours);
|
||||
behaviours.add(computerBehaviour = new ComputerBehaviour(this, () -> new SequencedGearshiftPeripheral(this)));
|
||||
behaviours.add(computerBehaviour = ComputerCraftProxy.behaviour(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -178,9 +178,8 @@ public class SequencedGearshiftTileEntity extends SplitShaftTileEntity {
|
|||
@NotNull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
|
||||
if (ComputerBehaviour.isPeripheralCap(cap))
|
||||
if (computerBehaviour.isPeripheralCap(cap))
|
||||
return computerBehaviour.getPeripheralCapability();
|
||||
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.compat.computercraft.ComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.peripherals.SpeedGaugePeripheral;
|
||||
import com.simibubi.create.compat.computercraft.AbstractComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.ComputerCraftProxy;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
|
@ -25,7 +25,7 @@ import net.minecraftforge.common.util.LazyOptional;
|
|||
|
||||
public class SpeedGaugeTileEntity extends GaugeTileEntity {
|
||||
|
||||
ComputerBehaviour computerBehaviour;
|
||||
public AbstractComputerBehaviour computerBehaviour;
|
||||
|
||||
public SpeedGaugeTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
|
@ -34,7 +34,7 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity {
|
|||
@Override
|
||||
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
|
||||
super.addBehaviours(behaviours);
|
||||
behaviours.add(computerBehaviour = new ComputerBehaviour(this, () -> new SpeedGaugePeripheral(this)));
|
||||
behaviours.add(computerBehaviour = ComputerCraftProxy.behaviour(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,9 +83,8 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity {
|
|||
@NotNull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
|
||||
if (ComputerBehaviour.isPeripheralCap(cap))
|
||||
if (computerBehaviour.isPeripheralCap(cap))
|
||||
return computerBehaviour.getPeripheralCapability();
|
||||
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.compat.computercraft.ComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.peripherals.StressGaugePeripheral;
|
||||
import com.simibubi.create.compat.computercraft.AbstractComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.ComputerCraftProxy;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate.StressImpact;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.item.ItemDescription;
|
||||
|
@ -29,7 +29,8 @@ import net.minecraftforge.common.util.LazyOptional;
|
|||
|
||||
public class StressGaugeTileEntity extends GaugeTileEntity {
|
||||
|
||||
ComputerBehaviour computerBehaviour;
|
||||
public AbstractComputerBehaviour computerBehaviour;
|
||||
|
||||
static BlockPos lastSent;
|
||||
|
||||
public StressGaugeTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
|
@ -39,7 +40,7 @@ public class StressGaugeTileEntity extends GaugeTileEntity {
|
|||
@Override
|
||||
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
|
||||
super.addBehaviours(behaviours);
|
||||
behaviours.add(computerBehaviour = new ComputerBehaviour(this, () -> new StressGaugePeripheral(this)));
|
||||
behaviours.add(computerBehaviour = ComputerCraftProxy.behaviour(this));
|
||||
registerAwardables(behaviours, AllAdvancements.STRESSOMETER, AllAdvancements.STRESSOMETER_MAXED);
|
||||
}
|
||||
|
||||
|
@ -154,9 +155,8 @@ public class StressGaugeTileEntity extends GaugeTileEntity {
|
|||
@NotNull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
|
||||
if (ComputerBehaviour.isPeripheralCap(cap))
|
||||
if (computerBehaviour.isPeripheralCap(cap))
|
||||
return computerBehaviour.getPeripheralCapability();
|
||||
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.compat.computercraft.ComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.peripherals.DisplayLinkPeripheral;
|
||||
import com.simibubi.create.compat.computercraft.AbstractComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.ComputerCraftProxy;
|
||||
import com.simibubi.create.content.logistics.block.display.source.DisplaySource;
|
||||
import com.simibubi.create.content.logistics.block.display.target.DisplayTarget;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
|
@ -41,7 +41,7 @@ public class DisplayLinkTileEntity extends SmartTileEntity {
|
|||
|
||||
public int refreshTicks;
|
||||
|
||||
ComputerBehaviour computerBehaviour;
|
||||
public AbstractComputerBehaviour computerBehaviour;
|
||||
|
||||
public DisplayLinkTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
|
@ -55,8 +55,7 @@ public class DisplayLinkTileEntity extends SmartTileEntity {
|
|||
|
||||
@Override
|
||||
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
|
||||
behaviours.add(computerBehaviour = new ComputerBehaviour(this, () -> new DisplayLinkPeripheral(this)));
|
||||
|
||||
behaviours.add(computerBehaviour = ComputerCraftProxy.behaviour(this));
|
||||
registerAwardables(behaviours, AllAdvancements.DISPLAY_LINK, AllAdvancements.DISPLAY_BOARD);
|
||||
}
|
||||
|
||||
|
@ -187,7 +186,7 @@ public class DisplayLinkTileEntity extends SmartTileEntity {
|
|||
@NotNull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
|
||||
if (ComputerBehaviour.isPeripheralCap(cap))
|
||||
if (computerBehaviour.isPeripheralCap(cap))
|
||||
return computerBehaviour.getPeripheralCapability();
|
||||
|
||||
return super.getCapability(cap, side);
|
||||
|
|
|
@ -19,8 +19,8 @@ import com.simibubi.create.AllBlocks;
|
|||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.compat.computercraft.ComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.peripherals.StationPeripheral;
|
||||
import com.simibubi.create.compat.computercraft.AbstractComputerBehaviour;
|
||||
import com.simibubi.create.compat.computercraft.ComputerCraftProxy;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.ITransformableTE;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform;
|
||||
|
@ -94,7 +94,7 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable
|
|||
protected int failedCarriageIndex;
|
||||
protected AssemblyException lastException;
|
||||
protected DepotBehaviour depotBehaviour;
|
||||
ComputerBehaviour computerBehaviour;
|
||||
public AbstractComputerBehaviour computerBehaviour;
|
||||
|
||||
// for display
|
||||
UUID imminentTrain;
|
||||
|
@ -126,7 +126,7 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable
|
|||
depotBehaviour.addSubBehaviours(behaviours);
|
||||
registerAwardables(behaviours, AllAdvancements.CONTRAPTION_ACTORS, AllAdvancements.TRAIN,
|
||||
AllAdvancements.LONG_TRAIN, AllAdvancements.CONDUCTOR);
|
||||
behaviours.add(computerBehaviour = new ComputerBehaviour(this, () -> new StationPeripheral(this)));
|
||||
behaviours.add(computerBehaviour = ComputerCraftProxy.behaviour(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -814,10 +814,8 @@ public class StationTileEntity extends SmartTileEntity implements ITransformable
|
|||
public <T> @NotNull LazyOptional<T> getCapability(@NotNull Capability<T> cap, Direction side) {
|
||||
if (isItemHandlerCap(cap))
|
||||
return depotBehaviour.getItemCapability(cap, side);
|
||||
|
||||
if (ComputerBehaviour.isPeripheralCap(cap))
|
||||
if (computerBehaviour.isPeripheralCap(cap))
|
||||
return computerBehaviour.getPeripheralCapability();
|
||||
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue