Fix CC peripherals

This commit is contained in:
Andrew-71 2023-08-03 18:07:34 +03:00
parent 4c6939e69f
commit b264703521
17 changed files with 189 additions and 138 deletions

View file

@ -1,58 +1,58 @@
package su.a71.tardim_ic.mixin; //package su.a71.tardim_ic.mixin;
//
import com.swdteam.tardim.common.command.tardim.CommandLocate; //import com.swdteam.tardim.common.command.tardim.CommandLocate;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase; //import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.tardim.TardimData; //import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager; //import com.swdteam.tardim.tardim.TardimManager;
import net.minecraft.core.BlockPos; //import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player; //import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; //import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin; //import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; //import org.spongepowered.asm.mixin.Overwrite;
//
import static com.swdteam.tardim.common.command.tardim.CommandTardimBase.sendResponse; //import static com.swdteam.tardim.common.command.tardim.CommandTardimBase.sendResponse;
//
@Mixin(value = CommandLocate.class, remap = false) //@Mixin(value = CommandLocate.class, remap = false)
public class JammerMixin { //public class JammerMixin {
// @Inject(method="execute()V", at=@At(value = "INVOKE", //// @Inject(method="execute()V", at=@At(value = "INVOKE",
// target = "Lcom/swdteam/tardim/tardim/TardimData;setTravelLocation(Lcom/swdteam/tardim/tardim/TardimData$Location;)V")) //// target = "Lcom/swdteam/tardim/tardim/TardimData;setTravelLocation(Lcom/swdteam/tardim/tardim/TardimData$Location;)V"))
// public void execute(CallbackInfo ci) { //// public void execute(CallbackInfo ci) {
// LOG.info("test"); //// LOG.info("test");
//// for (ItemStack armour : player.getArmorSlots()) { ////// for (ItemStack armour : player.getArmorSlots()) {
//// if (armour.is(LOCATION_JAMMER)) { ////// if (armour.is(LOCATION_JAMMER)) {
//// sendResponse(player, "Player's location is jammed", CommandTardimBase.ResponseType.FAIL, source); ////// sendResponse(player, "Player's location is jammed", CommandTardimBase.ResponseType.FAIL, source);
//// ci.cancel(); ////// ci.cancel();
//// }; ////// };
//// } ////// }
//// }
//
// @Overwrite
// public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
// if (args.length == 1) {
// TardimData data = TardimManager.getFromPos(pos);
// if (data != null) {
// if (data.hasPermission(player)) {
// Player otherPlayer = player.getServer().getPlayerList().getPlayerByName(args[0]);
// if (otherPlayer != null) {
// for (ItemStack armour : otherPlayer.getArmorSlots()) {
//// if (armour.is(PERSONAL_JAMMER)) {
//// sendResponse(player, otherPlayer.getGameProfile().getName() + "'s location is jammed", CommandTardimBase.ResponseType.FAIL, source);
//// return;
//// }
// // TODO: Re-add
// }
// data.setTravelLocation(new TardimData.Location(otherPlayer.blockPosition(), otherPlayer.level().dimension()));
// sendResponse(player, "Coords locked on to " + otherPlayer.getGameProfile().getName(), CommandTardimBase.ResponseType.COMPLETE, source);
// } else {
// sendResponse(player, "Player does not exist", CommandTardimBase.ResponseType.FAIL, source);
// }
// } else {
// sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
// }
// }
// } else {
// sendResponse(player, ((CommandLocate)(Object)this).getUsage(), CommandTardimBase.ResponseType.FAIL, source);
// }
//
// } // }
//}
@Overwrite
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
if (args.length == 1) {
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
Player otherPlayer = player.getServer().getPlayerList().getPlayerByName(args[0]);
if (otherPlayer != null) {
for (ItemStack armour : otherPlayer.getArmorSlots()) {
// if (armour.is(PERSONAL_JAMMER)) {
// sendResponse(player, otherPlayer.getGameProfile().getName() + "'s location is jammed", CommandTardimBase.ResponseType.FAIL, source);
// return;
// }
// TODO: Re-add
}
data.setTravelLocation(new TardimData.Location(otherPlayer.blockPosition(), otherPlayer.level().dimension()));
sendResponse(player, "Coords locked on to " + otherPlayer.getGameProfile().getName(), CommandTardimBase.ResponseType.COMPLETE, source);
} else {
sendResponse(player, "Player does not exist", CommandTardimBase.ResponseType.FAIL, source);
}
} else {
sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
}
}
} else {
sendResponse(player, ((CommandLocate)(Object)this).getUsage(), CommandTardimBase.ResponseType.FAIL, source);
}
}
}

View file

@ -2,6 +2,7 @@
"block.tardim_ic.digital_tardim_interface": "Digital TARDIM Interface", "block.tardim_ic.digital_tardim_interface": "Digital TARDIM Interface",
"block.tardim_ic.redstone_tardim_input": "Redstone TARDIM Input", "block.tardim_ic.redstone_tardim_input": "Redstone TARDIM Input",
"block.tardim_ic.tardim_dock": "TARDIM Dock", "block.tardim_ic.tardim_dock": "TARDIM Dock",
"block.tardim_ic.food_machine": "TARDIM food machine",
"itemGroup.tardim_ic": "TARDIM: In Control", "itemGroup.tardim_ic": "TARDIM: In Control",
"itemGroup.minecraft.tardim_ic": "TARDIM: In Control", "itemGroup.minecraft.tardim_ic": "TARDIM: In Control",
"subtitles.tardim_ic.cloister": "Cloister bell rings", "subtitles.tardim_ic.cloister": "Cloister bell rings",

View file

@ -2,6 +2,7 @@
"block.tardim_ic.digital_tardim_interface": "Digital TARDIM interface", "block.tardim_ic.digital_tardim_interface": "Digital TARDIM interface",
"block.tardim_ic.redstone_tardim_input": "Redstone TARDIM input", "block.tardim_ic.redstone_tardim_input": "Redstone TARDIM input",
"block.tardim_ic.tardim_dock": "TARDIM dock", "block.tardim_ic.tardim_dock": "TARDIM dock",
"block.tardim_ic.food_machine": "TARDIM food machine",
"itemGroup.tardim_ic": "TARDIM: In Control", "itemGroup.tardim_ic": "TARDIM: In Control",
"itemGroup.minecraft.tardim_ic": "TARDIM: In Control", "itemGroup.minecraft.tardim_ic": "TARDIM: In Control",
"subtitles.tardim_ic.cloister": "Cloister bell rings", "subtitles.tardim_ic.cloister": "Cloister bell rings",

View file

@ -2,6 +2,7 @@
"block.tardim_ic.digital_tardim_interface": "Цифровой интерфейс TARDIM", "block.tardim_ic.digital_tardim_interface": "Цифровой интерфейс TARDIM",
"block.tardim_ic.redstone_tardim_input": "Редстоуновый ввод TARDIM", "block.tardim_ic.redstone_tardim_input": "Редстоуновый ввод TARDIM",
"block.tardim_ic.tardim_dock": "Стыковочная станция для TARDIM", "block.tardim_ic.tardim_dock": "Стыковочная станция для TARDIM",
"block.tardim_ic.food_machine": "Раздатчик еды",
"itemGroup.tardim_ic": "TARDIM: In Control", "itemGroup.tardim_ic": "TARDIM: In Control",
"itemGroup.minecraft.tardim_ic": "TARDIM: In Control", "itemGroup.minecraft.tardim_ic": "TARDIM: In Control",
"subtitles.tardim_ic.cloister": "Звон монастырского колокола", "subtitles.tardim_ic.cloister": "Звон монастырского колокола",

View file

@ -16,6 +16,7 @@ dependencies {
implementation project(":common") implementation project(":common")
modImplementation("curse.maven:tardim-531315:4668945") modImplementation("curse.maven:tardim-531315:4668945")
// modCompileOnly("com.simibubi.create:create-fabric-1.20.1:0.5.1-d-build.1118+mc1.20.1")
modCompileOnly("cc.tweaked:cc-tweaked-$minecraft_version-fabric-api:$cc_version") modCompileOnly("cc.tweaked:cc-tweaked-$minecraft_version-fabric-api:$cc_version")
} }

View file

@ -38,7 +38,6 @@ public class FoodMachineBlock extends HorizontalDirectionalBlock implements Enti
public FoodMachineBlock() { public FoodMachineBlock() {
super(Properties.of().strength(2, 4).noOcclusion().mapColor(MapColor.METAL)); // No occlusion? super(Properties.of().strength(2, 4).noOcclusion().mapColor(MapColor.METAL)); // No occlusion?
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH)); this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
//this.registerDefaultState(this.stateDefinition.any().setValue(HORIZONTAL_FACING, Direction.NORTH));
} }
public BlockState getStateForPlacement(BlockPlaceContext $$0) { public BlockState getStateForPlacement(BlockPlaceContext $$0) {
@ -63,14 +62,13 @@ public class FoodMachineBlock extends HorizontalDirectionalBlock implements Enti
if (be instanceof FoodMachineBlockEntity && w.dimension() == TRDDimensions.TARDIS) { if (be instanceof FoodMachineBlockEntity && w.dimension() == TRDDimensions.TARDIS) {
TardimData data = TardimManager.getFromPos(blockPos); TardimData data = TardimManager.getFromPos(blockPos);
if (data != null && data.hasPermission(player)) { if (data != null && data.hasPermission(player)) {
if (data.getFuel() >= 0.05) { if (data.getFuel() >= 0.2) {
data.setFuel(data.getFuel() - 0.05); // Remove some fuel in exchange for food data.setFuel(data.getFuel() - 0.2); // Remove some fuel in exchange for food
ItemEntity food = new ItemEntity(EntityType.ITEM, w); ItemEntity food = new ItemEntity(EntityType.ITEM, w);
// Select type of food here // Select type of food here
food.setItem(new ItemStack(Items.BREAD, 1)); food.setItem(new ItemStack(Items.BREAD, 1));
food.setPos(Vec3.atCenterOf(blockPos).add(new Vec3(0, 0.2, 0))); food.setPos(Vec3.atCenterOf(blockPos).add(new Vec3(0, 0.2, 0)));
w.addFreshEntity(food); w.addFreshEntity(food);
} else { } else {

View file

@ -9,6 +9,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import su.a71.tardim_ic.tardim_ic.registration.Registration;
/* /*
@ -24,15 +25,14 @@ public class CommandCloisterBell implements ICommand {
try { try {
Level lvl = player.level(); Level lvl = player.level();
if (!lvl.isClientSide) { if (!lvl.isClientSide) {
// lvl.playSound( lvl.playSound(
// null, null,
// pos, pos,
// Registration.CLOISTER_SOUND_EVENT, Registration.CLOISTER_BELL,
// SoundSource.BLOCKS, SoundSource.BLOCKS,
// 1.5f, 1.5f,
// 1f 1f
// ); );
// TODO: Re-add
} }
} catch (Exception var9) { } catch (Exception var9) {
CommandTardimBase.sendResponse(player, "There was an error", CommandTardimBase.ResponseType.FAIL, source); CommandTardimBase.sendResponse(player, "There was an error", CommandTardimBase.ResponseType.FAIL, source);

View file

@ -37,6 +37,7 @@ import net.minecraft.world.phys.Vec3;
import su.a71.tardim_ic.computercraft_compat.digital_interface.DigitalInterfaceBlock; import su.a71.tardim_ic.computercraft_compat.digital_interface.DigitalInterfaceBlock;
import su.a71.tardim_ic.computercraft_compat.entity.FakeTardimPeripheralTileEntity; import su.a71.tardim_ic.computercraft_compat.entity.FakeTardimPeripheralTileEntity;
import su.a71.tardim_ic.tardim_ic.registration.Registration;
import su.a71.tardim_ic.utils.FakePlayer; import su.a71.tardim_ic.utils.FakePlayer;
import java.util.*; import java.util.*;
@ -150,7 +151,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/ */
@LuaFunction(mainThread = true) @LuaFunction(mainThread = true)
public final ObjectLuaTable getCurrentLocation() throws LuaException { public final ObjectLuaTable getCurrentLocation() throws LuaException {
Location loc = getTardimData().getCurrentLocation(); Location loc = getTardimData().getCurrentLocation();
return new ObjectLuaTable(Map.of( return new ObjectLuaTable(Map.of(
"dimension", loc.getLevel().location().toString(), "dimension", loc.getLevel().location().toString(),
"pos", new ObjectLuaTable(Map.of( "pos", new ObjectLuaTable(Map.of(
@ -175,7 +176,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/ */
@LuaFunction(mainThread = true) @LuaFunction(mainThread = true)
public final ObjectLuaTable getTravelLocation() throws LuaException { public final ObjectLuaTable getTravelLocation() throws LuaException {
TardimData data = getTardimData(); TardimData data = getTardimData();
if (data.getTravelLocation() == null) { if (data.getTravelLocation() == null) {
data.setTravelLocation(data.getCurrentLocation()); data.setTravelLocation(data.getCurrentLocation());
} }
@ -197,12 +198,12 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/ */
@LuaFunction(mainThread = true) @LuaFunction(mainThread = true)
public final ObjectLuaTable getCompanions() throws LuaException { public final ObjectLuaTable getCompanions() throws LuaException {
TardimData data = getTardimData(); TardimData data = getTardimData();
Map<Integer, String> companions = new HashMap<>(); Map<Integer, String> companions = new HashMap<>();
for (int i = 0; i < data.getCompanions().size(); i++) { for (int i = 0; i < data.getCompanions().size(); i++) {
companions.put(i + 1, data.getCompanions().get(i).getUsername()); companions.put(i + 1, data.getCompanions().get(i).getUsername());
} }
return new ObjectLuaTable(companions); return new ObjectLuaTable(companions);
} }
/** /**
@ -255,7 +256,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/ */
@LuaFunction(mainThread = true) @LuaFunction(mainThread = true)
public final void setDimension(String dimension) throws LuaException { public final void setDimension(String dimension) throws LuaException {
TardimData data = getTardimData(); TardimData data = getTardimData();
String key = dimension; String key = dimension;
dimension = toTitleCase(dimension); dimension = toTitleCase(dimension);
@ -302,7 +303,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
if (this.getTileEntity().getLevel().isClientSide()) { if (this.getTileEntity().getLevel().isClientSide()) {
return; return;
} }
TardimData data = getTardimData(); TardimData data = getTardimData();
UUID uuid = data.getOwner(); UUID uuid = data.getOwner();
String username = data.getOwnerName(); String username = data.getOwnerName();
@ -339,9 +340,9 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
PlayerList playerList = this.getTileEntity().getLevel().getServer().getPlayerList(); PlayerList playerList = this.getTileEntity().getLevel().getServer().getPlayerList();
ServerPlayer player = playerList.getPlayerByName(username); ServerPlayer player = playerList.getPlayerByName(username);
if (player == null) { if (player == null) {
throw new LuaException("Player not found"); throw new LuaException("Player not found");
} }
for (ItemStack armour : player.getArmorSlots()) { for (ItemStack armour : player.getArmorSlots()) {
// if (armour.is(PERSONAL_JAMMER)) { // if (armour.is(PERSONAL_JAMMER)) {
@ -350,11 +351,11 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
// TODO: Re-add // TODO: Re-add
} }
ResourceKey<Level> dim = player.getCommandSenderWorld().dimension(); ResourceKey<Level> dim = player.getCommandSenderWorld().dimension();
BlockPos pos = player.blockPosition(); BlockPos pos = player.blockPosition();
setDimension(dim.location().toString()); setDimension(dim.location().toString());
setTravelLocation(pos.getX(), pos.getY(), pos.getZ()); setTravelLocation(pos.getX(), pos.getY(), pos.getZ());
} }
/** /**
@ -368,13 +369,13 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
return null; return null;
} }
PlayerList playerList = this.getTileEntity().getLevel().getServer().getPlayerList(); PlayerList playerList = this.getTileEntity().getLevel().getServer().getPlayerList();
Map<Integer, String> players = new HashMap<>(); Map<Integer, String> players = new HashMap<>();
for (int i = 0; i < playerList.getPlayers().size(); i++) { for (int i = 0; i < playerList.getPlayers().size(); i++) {
players.put(i + 1, playerList.getPlayers().get(i).getGameProfile().getName()); players.put(i + 1, playerList.getPlayers().get(i).getGameProfile().getName());
} }
return new ObjectLuaTable(players); return new ObjectLuaTable(players);
} }
/** /**
@ -383,8 +384,8 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/ */
@LuaFunction(mainThread = true) @LuaFunction(mainThread = true)
public final String getDoorRotation() throws LuaException { public final String getDoorRotation() throws LuaException {
TardimData data = getTardimData(); TardimData data = getTardimData();
Direction rotation = data.getTravelLocation().getFacing(); Direction rotation = data.getTravelLocation().getFacing();
switch (rotation) { switch (rotation) {
case NORTH -> { case NORTH -> {
return "north"; return "north";
@ -410,7 +411,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/ */
@LuaFunction(mainThread = true) @LuaFunction(mainThread = true)
public final void setDoorRotation(String rotation) throws LuaException { public final void setDoorRotation(String rotation) throws LuaException {
TardimData data = getTardimData(); TardimData data = getTardimData();
switch (rotation) { switch (rotation) {
case "north" -> data.getTravelLocation().setFacing(Direction.NORTH); case "north" -> data.getTravelLocation().setFacing(Direction.NORTH);
case "east" -> data.getTravelLocation().setFacing(Direction.EAST); case "east" -> data.getTravelLocation().setFacing(Direction.EAST);
@ -427,7 +428,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/ */
@LuaFunction(mainThread = true) @LuaFunction(mainThread = true)
public final void toggleDoorRotation() throws LuaException { public final void toggleDoorRotation() throws LuaException {
TardimData data = getTardimData(); TardimData data = getTardimData();
if (data.getTravelLocation() == null) { if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation())); data.setTravelLocation(new Location(data.getCurrentLocation()));
} }
@ -454,18 +455,18 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/ */
@LuaFunction(mainThread = true) @LuaFunction(mainThread = true)
public final void coordAdd(String axis, int amount) throws LuaException { public final void coordAdd(String axis, int amount) throws LuaException {
TardimData data = getTardimData(); TardimData data = getTardimData();
if (data.getTravelLocation() == null) { if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation())); data.setTravelLocation(new Location(data.getCurrentLocation()));
} }
Location location = data.getTravelLocation(); Location location = data.getTravelLocation();
switch (axis) { switch (axis) {
case "x" -> location.addPosition(amount, 0, 0); case "x" -> location.addPosition(amount, 0, 0);
case "y" -> location.addPosition(0, amount, 0); case "y" -> location.addPosition(0, amount, 0);
case "z" -> location.addPosition(0, 0, amount); case "z" -> location.addPosition(0, 0, amount);
default -> throw new LuaException("Invalid axis"); default -> throw new LuaException("Invalid axis");
} }
} }
/** /**
@ -477,7 +478,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
return; return;
} }
TardimData data = getTardimData(); TardimData data = getTardimData();
if (data.isInFlight()) { if (data.isInFlight()) {
throw new LuaException("TARDIM is already in flight"); throw new LuaException("TARDIM is already in flight");
@ -486,7 +487,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(loc.getLevel()); ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(loc.getLevel());
ItemTardim.destroyTardim(level, loc.getPos(), Direction.NORTH); ItemTardim.destroyTardim(level, loc.getPos(), Direction.NORTH);
data.setInFlight(true); data.setInFlight(true);
if (data.getTravelLocation() == null) { if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation())); data.setTravelLocation(new Location(data.getCurrentLocation()));
} }
@ -776,15 +777,14 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
try { try {
Level lvl = this.tileEntity.getLevel(); Level lvl = this.tileEntity.getLevel();
if (!lvl.isClientSide) { if (!lvl.isClientSide) {
// lvl.playSound( lvl.playSound(
// null, null,
// this.tileEntity.getPos(), this.tileEntity.getPos(),
// Registration.CLOISTER_SOUND_EVENT, Registration.CLOISTER_BELL,
// SoundSource.BLOCKS, SoundSource.BLOCKS,
// 1.5f, 1.5f,
// 1f 1f
// ); );
// TODO: Re-add
} }
} catch (Exception var9) { } catch (Exception var9) {
throw new LuaException("There was an error trying to play the sound"); throw new LuaException("There was an error trying to play the sound");

View file

@ -1,7 +1,6 @@
package su.a71.tardim_ic.mixin; package su.a71.tardim_ic.mixin;
import com.swdteam.tardim.tardim.TardimManager; import com.swdteam.tardim.tardim.TardimManager;
import com.swdteam.tardim.tileentity.TileEntityFuelStorage;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -10,7 +9,7 @@ import org.spongepowered.asm.mixin.Overwrite;
import static com.swdteam.tardim.tardim.TardimManager.FUEL_MAP; import static com.swdteam.tardim.tardim.TardimManager.FUEL_MAP;
// This mixin aims to make TARDIM fuel system less awful by allowing users to put standard furnace fuel into it. // This mixin aims to make TARDIM fuel system less awful by allowing users to put standard furnace fuel into it.
@Mixin(value = TardimManager.class, remap = false) @Mixin(value = TardimManager.class, remap = true)
public class BetterFuelMapMixin { public class BetterFuelMapMixin {
@Overwrite @Overwrite

View file

@ -24,7 +24,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import static su.a71.tardim_ic.Constants.LOG; import static su.a71.tardim_ic.Constants.LOG;
@Mixin(value = TileEntityFuelStorage.class, remap = false) @Mixin(value = TileEntityFuelStorage.class, remap = true)
public class BetterFuelStorageMixin { public class BetterFuelStorageMixin {
// This is rather inefficient as we iterate 2 times // This is rather inefficient as we iterate 2 times

View file

@ -1,24 +1,27 @@
package su.a71.tardim_ic.tardim_ic.registration; package su.a71.tardim_ic.tardim_ic.registration;
import com.swdteam.tardim.common.init.CommandManager; import com.swdteam.tardim.common.block.BlockFuelStorage;
import dan200.computercraft.api.ComputerCraftAPI; import com.swdteam.tardim.common.block.BlockRotor;
import com.swdteam.tardim.common.block.BlockTardimScanner;
import dan200.computercraft.api.peripheral.PeripheralLookup; import dan200.computercraft.api.peripheral.PeripheralLookup;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import su.a71.tardim_ic.Constants; import su.a71.tardim_ic.Constants;
import su.a71.tardim_ic.command.CommandModemTransmit;
import su.a71.tardim_ic.computercraft_compat.digital_interface.DigitalInterfaceBlock; import su.a71.tardim_ic.computercraft_compat.digital_interface.DigitalInterfaceBlock;
import su.a71.tardim_ic.computercraft_compat.digital_interface.DigitalInterfaceTileEntity; import su.a71.tardim_ic.computercraft_compat.digital_interface.DigitalInterfaceTileEntity;
import su.a71.tardim_ic.computercraft_compat.entity.FakeTardimPeripheralTileEntity;
import su.a71.tardim_ic.computercraft_compat.peripherals.DigitalInterfacePeripheral;
import su.a71.tardim_ic.computercraft_compat.peripherals.FuelStoragePeripheral;
import su.a71.tardim_ic.computercraft_compat.peripherals.TardimScannerPeripheral;
import su.a71.tardim_ic.computercraft_compat.peripherals.TimeRotorPeripheral;
import static com.swdteam.tardim.common.init.TRDBlocks.*;
import static su.a71.tardim_ic.tardim_ic.registration.Registration.registerBlock; import static su.a71.tardim_ic.tardim_ic.registration.Registration.registerBlock;
//import su.a71.tardim_ic.computercraft_compat.blocks.digital_interface.DigitalInterfaceTileEntity;
public class ComputerCraftCompat { public class ComputerCraftCompat {
public static final Block DIGITAL_TARDIM_INTERFACE = new DigitalInterfaceBlock(); public static final Block DIGITAL_TARDIM_INTERFACE = new DigitalInterfaceBlock();
@ -32,15 +35,22 @@ public class ComputerCraftCompat {
public static void register() { public static void register() {
Constants.LOG.info("Loaded ComputerCraft compatibility!"); Constants.LOG.info("Loaded ComputerCraft compatibility!");
registerBlock("digital_tardim_interface", () -> DIGITAL_TARDIM_INTERFACE, null); registerBlock("digital_tardim_interface", () -> DIGITAL_TARDIM_INTERFACE, null);
//
// Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "digital_tardim_interface"), DIGITAL_TARDIM_INTERFACE);
// Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "digital_tardim_interface"), new BlockItem(DIGITAL_TARDIM_INTERFACE, new FabricItemSettings().tab(Registration.TARDIM_IC_TAB)));
// CommandManager.register(new CommandModemTransmit()); PeripheralLookup.get().registerForBlockEntity((entity, direction) -> new DigitalInterfacePeripheral(new FakeTardimPeripheralTileEntity(entity.getBlockPos(), entity.getLevel())), DIGITAL_INTERFACE_BE);
// PeripheralLookup.get().registerSelf(); PeripheralLookup.get().registerForBlocks((world, pos, state, blockEntity, direction) -> {
if (state.getBlock() instanceof BlockFuelStorage) {
return new FuelStoragePeripheral(new FakeTardimPeripheralTileEntity(pos, world));
} else if (state.getBlock() instanceof BlockRotor) {
return new TimeRotorPeripheral(new FakeTardimPeripheralTileEntity(pos, world));
} else if (state.getBlock() instanceof BlockTardimScanner) {
return new TardimScannerPeripheral(new FakeTardimPeripheralTileEntity(pos, world));
}
return null;
}, FUEL_STORAGE, SCANNER, ROTOR);
}
// ComputerCraftAPI.registerPeripheralProvider(new TardimPeripheralProvider()); public static void addToTab(CreativeModeTab.ItemDisplayParameters itemDisplayParameters, CreativeModeTab.Output output) {
output.accept(DIGITAL_TARDIM_INTERFACE);
} }
} }

View file

@ -17,4 +17,6 @@ public class CreateCompat {
// AllDisplayBehaviours.assignBlockEntity(AllDisplayBehaviours.register(new ResourceLocation(Constants.MOD_ID, "fuel_storage_display_source"), new FuelLevelDisplaySource()), TILE_FUEL_STORAGE); // AllDisplayBehaviours.assignBlockEntity(AllDisplayBehaviours.register(new ResourceLocation(Constants.MOD_ID, "fuel_storage_display_source"), new FuelLevelDisplaySource()), TILE_FUEL_STORAGE);
// AllDisplayBehaviours.assignBlockEntity(AllDisplayBehaviours.register(new ResourceLocation(Constants.MOD_ID, "fuel_required_display_source"), new RequiredFuelDisplaySource()), TILE_FUEL_STORAGE); // AllDisplayBehaviours.assignBlockEntity(AllDisplayBehaviours.register(new ResourceLocation(Constants.MOD_ID, "fuel_required_display_source"), new RequiredFuelDisplaySource()), TILE_FUEL_STORAGE);
} }
} }

View file

@ -1,13 +1,19 @@
package su.a71.tardim_ic.tardim_ic.registration; package su.a71.tardim_ic.tardim_ic.registration;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import su.a71.tardim_ic.Constants; import su.a71.tardim_ic.Constants;
@ -25,34 +31,46 @@ public class Registration {
public static final Block REDSTONE_INPUT = new RedstoneInputBlock(); public static final Block REDSTONE_INPUT = new RedstoneInputBlock();
public static final BlockEntityType<RedstoneInputBlockEntity> REDSTONE_INPUT_BE = Registry.register( public static final BlockEntityType<RedstoneInputBlockEntity> REDSTONE_INPUT_BE = Registry.register(
BuiltInRegistries.BLOCK_ENTITY_TYPE, BuiltInRegistries.BLOCK_ENTITY_TYPE,
new ResourceLocation("tardim_ic", "redstone_tardim_input"), new ResourceLocation(Constants.MOD_ID, "redstone_tardim_input"),
FabricBlockEntityTypeBuilder.create(RedstoneInputBlockEntity::new, REDSTONE_INPUT).build() FabricBlockEntityTypeBuilder.create(RedstoneInputBlockEntity::new, REDSTONE_INPUT).build()
); );
public static final Block FOOD_MACHINE = new FoodMachineBlock(); public static final Block FOOD_MACHINE = new FoodMachineBlock();
public static final BlockEntityType<FoodMachineBlockEntity> FOOD_MACHINE_BE = Registry.register( public static final BlockEntityType<FoodMachineBlockEntity> FOOD_MACHINE_BE = Registry.register(
BuiltInRegistries.BLOCK_ENTITY_TYPE, BuiltInRegistries.BLOCK_ENTITY_TYPE,
new ResourceLocation("tardim_ic", "food_machine"), new ResourceLocation(Constants.MOD_ID, "food_machine"),
FabricBlockEntityTypeBuilder.create(FoodMachineBlockEntity::new, FOOD_MACHINE).build() FabricBlockEntityTypeBuilder.create(FoodMachineBlockEntity::new, FOOD_MACHINE).build()
); );
public static final SoundEvent CLOISTER_BELL = SoundEvent.createVariableRangeEvent(new ResourceLocation(Constants.MOD_ID, "cloister"));
public static final CreativeModeTab TAB = FabricItemGroup.builder()
.icon(() -> new ItemStack(REDSTONE_INPUT))
.title(Component.translatable("itemGroup.tardim_ic"))
.displayItems(((itemDisplayParameters, output) -> {
output.accept(REDSTONE_INPUT);
output.accept(FOOD_MACHINE);
if (FabricLoader.getInstance().isModLoaded("computercraft")) {
ComputerCraftCompat.addToTab(itemDisplayParameters, output);
}
}))
.build();
public static void registerBlock(String name, Supplier<? extends Block> supplier, CreativeModeTab tab) public static void registerBlock(String name, Supplier<? extends Block> supplier, CreativeModeTab tab)
{ {
Registry.register(BuiltInRegistries.BLOCK, new ResourceLocation(Constants.MOD_ID, name), supplier.get()); Registry.register(BuiltInRegistries.BLOCK, new ResourceLocation(Constants.MOD_ID, name), supplier.get());
BlockItem blockItem = new BlockItem(supplier.get(), new FabricItemSettings()); BlockItem blockItem = new BlockItem(supplier.get(), new FabricItemSettings());
Registry.register(BuiltInRegistries.ITEM, new ResourceLocation(Constants.MOD_ID, name), blockItem); Registry.register(BuiltInRegistries.ITEM, new ResourceLocation(Constants.MOD_ID, name), blockItem);
// Optional<ResourceKey<CreativeModeTab>> key = Optional.ofNullable(BuiltInRegistries.CREATIVE_MODE_TAB.getKey(tab));
// key.ifPresent(itemGroupRegistryKey -> ItemGroupEvents.modifyEntriesEvent(itemGroupRegistryKey).register(content -> {
// content.add(blockItem);
// }));
} }
public static void register() { public static void register() {
Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, new ResourceLocation("tardim_ic", "item_group"), TAB);
registerBlock("redstone_tardim_input", () -> REDSTONE_INPUT, null); registerBlock("redstone_tardim_input", () -> REDSTONE_INPUT, null);
registerBlock("food_machine", () -> FOOD_MACHINE, null); registerBlock("food_machine", () -> FOOD_MACHINE, null);
Registry.register(BuiltInRegistries.SOUND_EVENT, new ResourceLocation(Constants.MOD_ID, "cloister"), CLOISTER_BELL);
Exteriors.register(); Exteriors.register();
if (FabricLoader.getInstance().isModLoaded("computercraft")) { if (FabricLoader.getInstance().isModLoaded("computercraft")) {
ComputerCraftCompat.register(); ComputerCraftCompat.register();

View file

@ -5,6 +5,9 @@
"refmap": "${mod_id}.refmap.json", "refmap": "${mod_id}.refmap.json",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"mixins": [ "mixins": [
"CommandsMixin",
"BetterFuelStorageMixin",
"BetterFuelMapMixin"
], ],
"client": [ "client": [
], ],

View file

@ -63,6 +63,21 @@ subprojects {
url "https://cursemaven.com" url "https://cursemaven.com"
} }
} }
// Create Fabric 1.20 (Jeez that's a lot of mavens)
// maven {
// name "devOSSnapshots"
// url "https://mvn.devos.one/snapshots"
// }
// maven {
// name "tterrag maven"
// url "https://maven.tterrag.com/"
// }
// maven {
// url "https://maven.jamieswhiteshirt.com/libs-release"
// content {
// includeGroup "com.jamieswhiteshirt"
// }
// }
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
@ -81,7 +96,6 @@ subprojects {
// metadata includes mapped dependencies which are not reasonably consumable by // metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers. // other mod developers.
tasks.withType(GenerateModuleMetadata).configureEach { tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false enabled = false
} }
} }

View file

@ -3,7 +3,7 @@ If you have ComputerCraft: Tweaked installed,
TARDIM: IC provides quite a few peripherals. TARDIM: IC provides quite a few peripherals.
The main one is new Digital TARDIM Interface, The main one is new Digital TARDIM Interface,
which gives you complete control over your TARDIM. which gives you complete control over your TARDIM.
However, some TARDIM blocks also recieve getters for information related to them. However, some TARDIM blocks also receive getters for information related to them.
## ComputerCraft for beginners ## ComputerCraft for beginners
ComputerCraft adds working computers to minecraft, controlled by Lua language. ComputerCraft adds working computers to minecraft, controlled by Lua language.

View file

@ -1 +1,4 @@
# Digital TARDIM Interface # Digital TARDIM Interface
This peripheral allows you to do basically anything any other TARDI< control panel can, but automatically.
### Methods