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;
import com.swdteam.tardim.common.command.tardim.CommandLocate;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import static com.swdteam.tardim.common.command.tardim.CommandTardimBase.sendResponse;
@Mixin(value = CommandLocate.class, remap = false)
public class JammerMixin {
// @Inject(method="execute()V", at=@At(value = "INVOKE",
// target = "Lcom/swdteam/tardim/tardim/TardimData;setTravelLocation(Lcom/swdteam/tardim/tardim/TardimData$Location;)V"))
// public void execute(CallbackInfo ci) {
// LOG.info("test");
//// for (ItemStack armour : player.getArmorSlots()) {
//// if (armour.is(LOCATION_JAMMER)) {
//// sendResponse(player, "Player's location is jammed", CommandTardimBase.ResponseType.FAIL, source);
//// ci.cancel();
//// };
//// }
//package su.a71.tardim_ic.mixin;
//
//import com.swdteam.tardim.common.command.tardim.CommandLocate;
//import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
//import com.swdteam.tardim.tardim.TardimData;
//import com.swdteam.tardim.tardim.TardimManager;
//import net.minecraft.core.BlockPos;
//import net.minecraft.world.entity.player.Player;
//import net.minecraft.world.item.ItemStack;
//import org.spongepowered.asm.mixin.Mixin;
//import org.spongepowered.asm.mixin.Overwrite;
//
//import static com.swdteam.tardim.common.command.tardim.CommandTardimBase.sendResponse;
//
//@Mixin(value = CommandLocate.class, remap = false)
//public class JammerMixin {
//// @Inject(method="execute()V", at=@At(value = "INVOKE",
//// target = "Lcom/swdteam/tardim/tardim/TardimData;setTravelLocation(Lcom/swdteam/tardim/tardim/TardimData$Location;)V"))
//// public void execute(CallbackInfo ci) {
//// LOG.info("test");
////// for (ItemStack armour : player.getArmorSlots()) {
////// if (armour.is(LOCATION_JAMMER)) {
////// sendResponse(player, "Player's location is jammed", CommandTardimBase.ResponseType.FAIL, source);
////// 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.redstone_tardim_input": "Redstone TARDIM Input",
"block.tardim_ic.tardim_dock": "TARDIM Dock",
"block.tardim_ic.food_machine": "TARDIM food machine",
"itemGroup.tardim_ic": "TARDIM: In Control",
"itemGroup.minecraft.tardim_ic": "TARDIM: In Control",
"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.redstone_tardim_input": "Redstone TARDIM input",
"block.tardim_ic.tardim_dock": "TARDIM dock",
"block.tardim_ic.food_machine": "TARDIM food machine",
"itemGroup.tardim_ic": "TARDIM: In Control",
"itemGroup.minecraft.tardim_ic": "TARDIM: In Control",
"subtitles.tardim_ic.cloister": "Cloister bell rings",

View file

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

View file

@ -16,6 +16,7 @@ dependencies {
implementation project(":common")
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")
}

View file

@ -38,7 +38,6 @@ public class FoodMachineBlock extends HorizontalDirectionalBlock implements Enti
public FoodMachineBlock() {
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(HORIZONTAL_FACING, Direction.NORTH));
}
public BlockState getStateForPlacement(BlockPlaceContext $$0) {
@ -63,14 +62,13 @@ public class FoodMachineBlock extends HorizontalDirectionalBlock implements Enti
if (be instanceof FoodMachineBlockEntity && w.dimension() == TRDDimensions.TARDIS) {
TardimData data = TardimManager.getFromPos(blockPos);
if (data != null && data.hasPermission(player)) {
if (data.getFuel() >= 0.05) {
data.setFuel(data.getFuel() - 0.05); // Remove some fuel in exchange for food
if (data.getFuel() >= 0.2) {
data.setFuel(data.getFuel() - 0.2); // Remove some fuel in exchange for food
ItemEntity food = new ItemEntity(EntityType.ITEM, w);
// Select type of food here
food.setItem(new ItemStack(Items.BREAD, 1));
food.setPos(Vec3.atCenterOf(blockPos).add(new Vec3(0, 0.2, 0)));
w.addFreshEntity(food);
} else {

View file

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

View file

@ -1,7 +1,6 @@
package su.a71.tardim_ic.mixin;
import com.swdteam.tardim.tardim.TardimManager;
import com.swdteam.tardim.tileentity.TileEntityFuelStorage;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
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;
// 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 {
@Overwrite

View file

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

View file

@ -1,24 +1,27 @@
package su.a71.tardim_ic.tardim_ic.registration;
import com.swdteam.tardim.common.init.CommandManager;
import dan200.computercraft.api.ComputerCraftAPI;
import com.swdteam.tardim.common.block.BlockFuelStorage;
import com.swdteam.tardim.common.block.BlockRotor;
import com.swdteam.tardim.common.block.BlockTardimScanner;
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.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
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.entity.BlockEntityType;
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.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 su.a71.tardim_ic.computercraft_compat.blocks.digital_interface.DigitalInterfaceTileEntity;
public class ComputerCraftCompat {
public static final Block DIGITAL_TARDIM_INTERFACE = new DigitalInterfaceBlock();
@ -32,15 +35,22 @@ public class ComputerCraftCompat {
public static void register() {
Constants.LOG.info("Loaded ComputerCraft compatibility!");
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().registerSelf();
PeripheralLookup.get().registerForBlockEntity((entity, direction) -> new DigitalInterfacePeripheral(new FakeTardimPeripheralTileEntity(entity.getBlockPos(), entity.getLevel())), DIGITAL_INTERFACE_BE);
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_required_display_source"), new RequiredFuelDisplaySource()), TILE_FUEL_STORAGE);
}
}

View file

@ -1,13 +1,19 @@
package su.a71.tardim_ic.tardim_ic.registration;
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.loader.api.FabricLoader;
import net.minecraft.core.Registry;
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.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.BlockItem;
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.entity.BlockEntityType;
import su.a71.tardim_ic.Constants;
@ -25,34 +31,46 @@ public class Registration {
public static final Block REDSTONE_INPUT = new RedstoneInputBlock();
public static final BlockEntityType<RedstoneInputBlockEntity> REDSTONE_INPUT_BE = Registry.register(
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()
);
public static final Block FOOD_MACHINE = new FoodMachineBlock();
public static final BlockEntityType<FoodMachineBlockEntity> FOOD_MACHINE_BE = Registry.register(
BuiltInRegistries.BLOCK_ENTITY_TYPE,
new ResourceLocation("tardim_ic", "food_machine"),
new ResourceLocation(Constants.MOD_ID, "food_machine"),
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)
{
Registry.register(BuiltInRegistries.BLOCK, new ResourceLocation(Constants.MOD_ID, name), supplier.get());
BlockItem blockItem = new BlockItem(supplier.get(), new FabricItemSettings());
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() {
Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, new ResourceLocation("tardim_ic", "item_group"), TAB);
registerBlock("redstone_tardim_input", () -> REDSTONE_INPUT, null);
registerBlock("food_machine", () -> FOOD_MACHINE, null);
Registry.register(BuiltInRegistries.SOUND_EVENT, new ResourceLocation(Constants.MOD_ID, "cloister"), CLOISTER_BELL);
Exteriors.register();
if (FabricLoader.getInstance().isModLoaded("computercraft")) {
ComputerCraftCompat.register();

View file

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

View file

@ -63,6 +63,21 @@ subprojects {
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 {
@ -81,7 +96,6 @@ subprojects {
// metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers.
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
}

View file

@ -3,7 +3,7 @@ If you have ComputerCraft: Tweaked installed,
TARDIM: IC provides quite a few peripherals.
The main one is new Digital TARDIM Interface,
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 adds working computers to minecraft, controlled by Lua language.

View file

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