Added PeripheralBase

This commit is contained in:
caelwarner 2022-10-04 19:36:08 -07:00
parent d404f07319
commit 9a80781401
No known key found for this signature in database
GPG Key ID: 514BEF5EADE889FF
7 changed files with 34 additions and 54 deletions

View File

@ -5,26 +5,22 @@ import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.simibubi.create.content.logistics.block.display.DisplayLinkTileEntity;
import dan200.computercraft.api.lua.IArguments;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
public class DisplayLinkPeripheral implements IPeripheral {
public class DisplayLinkPeripheral extends PeripheralBase<DisplayLinkTileEntity> {
public static final String TAG_KEY = "ComputerSourceList";
private final DisplayLinkTileEntity tile;
public DisplayLinkPeripheral(DisplayLinkTileEntity tile) {
this.tile = tile;
super(tile);
}
@LuaFunction
@ -127,9 +123,4 @@ public class DisplayLinkPeripheral implements IPeripheral {
return "Create_DisplayLink";
}
@Override
public boolean equals(@Nullable IPeripheral other) {
return this == other;
}
}

View File

@ -0,0 +1,21 @@
package com.simibubi.create.compat.computercraft;
import org.jetbrains.annotations.Nullable;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.world.level.block.entity.BlockEntity;
public abstract class PeripheralBase<T extends BlockEntity & ComputerControllable> implements IPeripheral {
protected T tile;
public PeripheralBase(T tile) {
this.tile = tile;
}
@Override
public boolean equals(@Nullable IPeripheral other) {
return this == other;
}
}

View File

@ -1,7 +1,6 @@
package com.simibubi.create.compat.computercraft;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.simibubi.create.content.contraptions.relays.advanced.sequencer.Instruction;
import com.simibubi.create.content.contraptions.relays.advanced.sequencer.InstructionSpeedModifiers;
@ -11,14 +10,11 @@ import com.simibubi.create.content.contraptions.relays.advanced.sequencer.Sequen
import dan200.computercraft.api.lua.IArguments;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.peripheral.IPeripheral;
public class SequencedGearshiftPeripheral implements IPeripheral {
private final SequencedGearshiftTileEntity tile;
public class SequencedGearshiftPeripheral extends PeripheralBase<SequencedGearshiftTileEntity> {
public SequencedGearshiftPeripheral(SequencedGearshiftTileEntity tile) {
this.tile = tile;
super(tile);
}
@LuaFunction(mainThread = true)
@ -55,9 +51,4 @@ public class SequencedGearshiftPeripheral implements IPeripheral {
return "Create_SequencedGearshift";
}
@Override
public boolean equals(@Nullable IPeripheral other) {
return this == other;
}
}

View File

@ -1,18 +1,18 @@
package com.simibubi.create.compat.computercraft;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerTileEntity;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.peripheral.IPeripheral;
public class SpeedControllerPeripheral implements IPeripheral {
public class SpeedControllerPeripheral extends PeripheralBase<SpeedControllerTileEntity> {
private final ScrollValueBehaviour targetSpeed;
public SpeedControllerPeripheral(ScrollValueBehaviour targetSpeed) {
public SpeedControllerPeripheral(SpeedControllerTileEntity tile, ScrollValueBehaviour targetSpeed) {
super(tile);
this.targetSpeed = targetSpeed;
}
@ -32,9 +32,4 @@ public class SpeedControllerPeripheral implements IPeripheral {
return "Create_RotationSpeedController";
}
@Override
public boolean equals(@Nullable IPeripheral other) {
return this == other;
}
}

View File

@ -1,19 +1,15 @@
package com.simibubi.create.compat.computercraft;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.simibubi.create.content.contraptions.relays.gauge.SpeedGaugeTileEntity;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.peripheral.IPeripheral;
public class SpeedGaugePeripheral implements IPeripheral {
private final SpeedGaugeTileEntity tile;
public class SpeedGaugePeripheral extends PeripheralBase<SpeedGaugeTileEntity> {
public SpeedGaugePeripheral(SpeedGaugeTileEntity tile) {
this.tile = tile;
super(tile);
}
@LuaFunction
@ -27,9 +23,4 @@ public class SpeedGaugePeripheral implements IPeripheral {
return "Create_Speedometer";
}
@Override
public boolean equals(@Nullable IPeripheral other) {
return this == other;
}
}

View File

@ -1,19 +1,15 @@
package com.simibubi.create.compat.computercraft;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.simibubi.create.content.contraptions.relays.gauge.StressGaugeTileEntity;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.peripheral.IPeripheral;
public class StressGaugePeripheral implements IPeripheral {
private final StressGaugeTileEntity tile;
public class StressGaugePeripheral extends PeripheralBase<StressGaugeTileEntity> {
public StressGaugePeripheral(StressGaugeTileEntity tile) {
this.tile = tile;
super(tile);
}
@LuaFunction
@ -32,9 +28,4 @@ public class StressGaugePeripheral implements IPeripheral {
return "Create_Stressometer";
}
@Override
public boolean equals(@Nullable IPeripheral other) {
return this == other;
}
}

View File

@ -153,7 +153,7 @@ public class SpeedControllerTileEntity extends KineticTileEntity implements Comp
@Override
public IPeripheral createPeripheral() {
return new SpeedControllerPeripheral(targetSpeed);
return new SpeedControllerPeripheral(this, targetSpeed);
}
@Override