The Masters Dalek Plan

This commit is contained in:
Andrew-71 2023-04-16 23:46:48 +03:00
parent f6a2fa93f2
commit 9e9412e53e
25 changed files with 492 additions and 139 deletions

View file

@ -10,7 +10,12 @@ import java.util.UUID;
public class FakePlayer extends Player { public class FakePlayer extends Player {
public FakePlayer(Level lvl, BlockPos blockPos) { public FakePlayer(Level lvl, BlockPos blockPos) {
super(lvl, blockPos, 0, new GameProfile(UUID.randomUUID(), "DigitalInterfaceFakePlayer"), null); super(lvl, blockPos, 0, new GameProfile(UUID.randomUUID(), "FakePlayer_tardimic"), null);
}
public FakePlayer(Level lvl, BlockPos blockPos, UUID id) {
super(lvl, blockPos, 0, new GameProfile(id, "FakePlayer_tardimic"), null);
} }
@Override @Override

View file

@ -1,9 +1,8 @@
{ {
"credit": "Made with Blockbench", "credit": "Made with Blockbench",
"render": "translucent",
"texture_size": [64, 64], "texture_size": [64, 64],
"textures": { "textures": {
"0": "tardim_ic:blocks/tardim_dock", "1": "tardim_ic:blocks/tardim_dock",
"particle": "tardim_ic:blocks/tardim_dock" "particle": "tardim_ic:blocks/tardim_dock"
}, },
"elements": [ "elements": [
@ -11,76 +10,128 @@
"from": [2, 0, 2], "from": [2, 0, 2],
"to": [14, 12, 14], "to": [14, 12, 14],
"faces": { "faces": {
"north": {"uv": [4, 0, 7, 3], "texture": "#0"}, "north": {"uv": [4, 0, 7, 3], "texture": "#1"},
"east": {"uv": [4, 3, 7, 6], "texture": "#0"}, "east": {"uv": [4, 3, 7, 6], "texture": "#1"},
"south": {"uv": [4, 6, 7, 9], "texture": "#0"}, "south": {"uv": [4, 6, 7, 9], "texture": "#1"},
"west": {"uv": [7, 0, 10, 3], "texture": "#0"}, "west": {"uv": [7, 0, 10, 3], "texture": "#1"},
"up": {"uv": [10, 6, 7, 3], "texture": "#0"}, "up": {"uv": [10, 6, 7, 3], "texture": "#1"},
"down": {"uv": [10, 6, 7, 9], "texture": "#0"} "down": {"uv": [10, 6, 7, 9], "texture": "#1"}
} }
}, },
{ {
"from": [0, 12, 0], "from": [0, 12, 0],
"to": [16, 16, 16], "to": [16, 16, 16],
"faces": { "faces": {
"north": {"uv": [0, 8, 4, 9], "texture": "#0"}, "north": {"uv": [0, 8, 4, 9], "texture": "#1"},
"east": {"uv": [0, 9, 4, 10], "texture": "#0"}, "east": {"uv": [0, 9, 4, 10], "texture": "#1"},
"south": {"uv": [4, 9, 8, 10], "texture": "#0"}, "south": {"uv": [4, 9, 8, 10], "texture": "#1"},
"west": {"uv": [8, 9, 12, 10], "texture": "#0"}, "west": {"uv": [8, 9, 12, 10], "texture": "#1"},
"up": {"uv": [4, 4, 0, 0], "texture": "#0"}, "up": {"uv": [4, 4, 0, 0], "texture": "#1"},
"down": {"uv": [4, 4, 0, 8], "texture": "#0"} "down": {"uv": [4, 4, 0, 8], "texture": "#1"}
} }
}, },
{ {
"from": [12, 0, 0], "from": [12, 7, 0],
"to": [12, 12, 2], "to": [12, 12, 1],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
"faces": { "faces": {
"north": {"uv": [0, 0, 0, 3], "texture": "#0"}, "north": {"uv": [0, 0, 0, 3], "texture": "#1"},
"east": {"uv": [10.5, 0, 10, 3], "texture": "#0"}, "east": {"uv": [10.25, 0, 10, 1.25], "texture": "#1"},
"south": {"uv": [0, 0, 0, 3], "texture": "#0"}, "south": {"uv": [0, 0, 0, 3], "texture": "#1"},
"west": {"uv": [10, 0, 10.5, 3], "texture": "#0"}, "west": {"uv": [10, 0, 10.25, 1.25], "texture": "#1"},
"up": {"uv": [0, 0.5, 0, 0], "texture": "#0"}, "up": {"uv": [0, 0.5, 0, 0], "texture": "#1"},
"down": {"uv": [0, 0, 0, 0.5], "texture": "#0"} "down": {"uv": [0, 0, 0, 0.5], "texture": "#1"}
} }
}, },
{ {
"from": [4, 0, 14], "from": [12, 6, 1],
"to": [12, 7, 2],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 3], "texture": "#1"},
"east": {"uv": [10.5, 1.25, 10.25, 1.5], "texture": "#1"},
"south": {"uv": [0, 0, 0, 3], "texture": "#1"},
"west": {"uv": [10.5, 1.25, 10.25, 1.5], "texture": "#1"},
"up": {"uv": [0, 0.5, 0, 0], "texture": "#1"},
"down": {"uv": [0, 0, 0, 0.5], "texture": "#1"}
}
},
{
"from": [4, 4, 0],
"to": [4, 12, 1],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 3], "texture": "#1"},
"east": {"uv": [1.25, 10, 1, 12], "texture": "#1"},
"south": {"uv": [0, 0, 0, 3], "texture": "#1"},
"west": {"uv": [1, 10, 1.25, 12], "texture": "#1"},
"up": {"uv": [0, 0.5, 0, 0], "texture": "#1"},
"down": {"uv": [0, 0, 0, 0.5], "texture": "#1"}
}
},
{
"from": [4, 3, 1],
"to": [4, 4, 2],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 3], "texture": "#1"},
"east": {"uv": [1.5, 12, 1.25, 12.25], "texture": "#1"},
"south": {"uv": [0, 0, 0, 3], "texture": "#1"},
"west": {"uv": [1.25, 12, 1.5, 12.25], "texture": "#1"},
"up": {"uv": [0, 0.5, 0, 0], "texture": "#1"},
"down": {"uv": [0, 0, 0, 0.5], "texture": "#1"}
}
},
{
"from": [4, 7, 15],
"to": [4, 12, 16], "to": [4, 12, 16],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
"faces": { "faces": {
"north": {"uv": [0, 0, 0, 3], "texture": "#0"}, "north": {"uv": [0, 0, 0, 3], "texture": "#1"},
"east": {"uv": [10, 0, 10.5, 3], "texture": "#0"}, "east": {"uv": [10, 0, 10.25, 1.25], "texture": "#1"},
"south": {"uv": [0, 0, 0, 3], "texture": "#0"}, "south": {"uv": [0, 0, 0, 3], "texture": "#1"},
"west": {"uv": [10.5, 0, 10, 3], "texture": "#0"}, "west": {"uv": [10.25, 0, 10, 1.25], "texture": "#1"},
"up": {"uv": [0, 0.5, 0, 0], "rotation": 180, "texture": "#0"}, "up": {"uv": [0, 0.5, 0, 0], "rotation": 180, "texture": "#1"},
"down": {"uv": [0, 0, 0, 0.5], "rotation": 180, "texture": "#0"} "down": {"uv": [0, 0, 0, 0.5], "rotation": 180, "texture": "#1"}
} }
}, },
{ {
"from": [4, 0, 0], "from": [4, 6, 14],
"to": [4, 12, 2], "to": [4, 7, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
"faces": { "faces": {
"north": {"uv": [0, 0, 0, 3], "texture": "#0"}, "north": {"uv": [0, 0, 0, 3], "texture": "#1"},
"east": {"uv": [1.5, 10, 1, 13], "texture": "#0"}, "east": {"uv": [10.5, 1.25, 10.25, 1.5], "texture": "#1"},
"south": {"uv": [0, 0, 0, 3], "texture": "#0"}, "south": {"uv": [0, 0, 0, 3], "texture": "#1"},
"west": {"uv": [1, 10, 1.5, 13], "texture": "#0"}, "west": {"uv": [10.5, 1.25, 10.25, 1.5], "texture": "#1"},
"up": {"uv": [0, 0.5, 0, 0], "texture": "#0"}, "up": {"uv": [0, 0.5, 0, 0], "rotation": 180, "texture": "#1"},
"down": {"uv": [0, 0, 0, 0.5], "texture": "#0"} "down": {"uv": [0, 0, 0, 0.5], "rotation": 180, "texture": "#1"}
} }
}, },
{ {
"from": [12, 0, 14], "from": [12, 4, 15],
"to": [12, 12, 16], "to": [12, 12, 16],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
"faces": { "faces": {
"north": {"uv": [0, 0, 0, 3], "texture": "#0"}, "north": {"uv": [0, 0, 0, 3], "texture": "#1"},
"east": {"uv": [1, 10, 1.5, 13], "texture": "#0"}, "east": {"uv": [1, 10, 1.25, 12], "texture": "#1"},
"south": {"uv": [0, 0, 0, 3], "texture": "#0"}, "south": {"uv": [0, 0, 0, 3], "texture": "#1"},
"west": {"uv": [1.5, 10, 1, 13], "texture": "#0"}, "west": {"uv": [1.25, 10, 1, 12], "texture": "#1"},
"up": {"uv": [0, 0.5, 0, 0], "rotation": 180, "texture": "#0"}, "up": {"uv": [0, 0.5, 0, 0], "rotation": 180, "texture": "#1"},
"down": {"uv": [0, 0, 0, 0.5], "rotation": 180, "texture": "#0"} "down": {"uv": [0, 0, 0, 0.5], "rotation": 180, "texture": "#1"}
}
},
{
"from": [12, 3, 14],
"to": [12, 4, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 3], "texture": "#1"},
"east": {"uv": [1.25, 12, 1.5, 12.25], "texture": "#1"},
"south": {"uv": [0, 0, 0, 3], "texture": "#1"},
"west": {"uv": [1.5, 12, 1.25, 12.25], "texture": "#1"},
"up": {"uv": [0, 0.5, 0, 0], "rotation": 180, "texture": "#1"},
"down": {"uv": [0, 0, 0, 0.5], "rotation": 180, "texture": "#1"}
} }
} }
], ],
@ -124,7 +175,24 @@
"origin": [8, 8, 8], "origin": [8, 8, 8],
"color": 0, "color": 0,
"nbt": "{}", "nbt": "{}",
"children": [0, 1, 2, 3, 4, 5] "children": [
0,
1,
{
"name": "group",
"origin": [8, 8, 8],
"color": 0,
"nbt": "{}",
"children": [2, 3, 4, 5]
},
{
"name": "group",
"origin": [8, 8, 8],
"color": 0,
"nbt": "{}",
"children": [6, 7, 8, 9]
}
]
} }
] ]
} }

View file

@ -1,8 +1,11 @@
package su.a71.tardim_ic.tardim_ic; package su.a71.tardim_ic.tardim_ic;
import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.ComputerCraftAPI;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
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.item.ItemStack;
@ -26,6 +29,10 @@ import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
import su.a71.tardim_ic.tardim_ic.tardim_dock.TardimDockBlock; import su.a71.tardim_ic.tardim_ic.tardim_dock.TardimDockBlock;
import su.a71.tardim_ic.tardim_ic.tardim_dock.TardimDockBlockEntity; import su.a71.tardim_ic.tardim_ic.tardim_dock.TardimDockBlockEntity;
import com.swdteam.tardim.tileentity.TileEntityFuelStorage;
import com.swdteam.tardim.common.block.BlockFuelStorage;
public class Registration { public class Registration {
// Blocks // Blocks
@ -58,6 +65,10 @@ public class Registration {
.icon(() -> new ItemStack(DIGITAL_TARDIM_INTERFACE)) .icon(() -> new ItemStack(DIGITAL_TARDIM_INTERFACE))
.build(); .build();
// Cloister bell
public static final ResourceLocation CLOISTER_SOUND = new ResourceLocation("tardim_ic:cloister");
public static SoundEvent CLOISTER_SOUND_EVENT = new SoundEvent(CLOISTER_SOUND);
// Register our stuff // Register our stuff
public static void register() { public static void register() {
@ -70,6 +81,8 @@ public class Registration {
Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "tardim_dock"), TARDIM_DOCK); Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "tardim_dock"), TARDIM_DOCK);
Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "tardim_dock"), new BlockItem(TARDIM_DOCK, new FabricItemSettings().tab(TARDIM_IC_TAB))); Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "tardim_dock"), new BlockItem(TARDIM_DOCK, new FabricItemSettings().tab(TARDIM_IC_TAB)));
Registry.register(Registry.SOUND_EVENT, CLOISTER_SOUND, CLOISTER_SOUND_EVENT);
ComputerCraftAPI.registerPeripheralProvider(new DigitalInterfacePeripheralProvider()); ComputerCraftAPI.registerPeripheralProvider(new DigitalInterfacePeripheralProvider());
CommandInit.init(); CommandInit.init();
} }

View file

@ -4,16 +4,13 @@ import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.common.command.tardim.ICommand; import com.swdteam.tardim.common.command.tardim.ICommand;
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.resources.ResourceKey;
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 com.swdteam.tardim.common.init.TRDDimensions;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import su.a71.tardim_ic.tardim_ic.Registration;
//import static com.swdteam.common.command.tardim.CommandTardimBase.sendResponse; import su.a71.tardim_ic.tardim_ic.Registration;
public class CommandCloisterBell implements ICommand { public class CommandCloisterBell implements ICommand {
@Override @Override
@ -34,8 +31,6 @@ public class CommandCloisterBell implements ICommand {
1f 1f
); );
} }
CommandTardimBase.sendResponse(player, "<Insert Cloister bell>", CommandTardimBase.ResponseType.COMPLETE, source);
} 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);
} }
@ -55,7 +50,7 @@ public class CommandCloisterBell implements ICommand {
@Override @Override
public String getUsage() { public String getUsage() {
return "cloister-bell"; return "/cloister-bell";
} }
@Override @Override

View file

@ -0,0 +1,34 @@
package su.a71.tardim_ic.tardim_ic.mixin;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.ComparatorBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.ComparatorBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.swdteam.tardim.tileentity.TileEntityFuelStorage;
//@Mixin(TileEntityFuelStorage.class)
//public class FuelTank extends BlockEntity, ComparatorBlockEntity {
//
// public ExampleMixin(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
// super(blockEntityType, blockPos, blockState);
// }
//
// @Inject(at = @At("HEAD"), method = "init()V")
// private void init(CallbackInfo info) {
//
// Constants.LOG.info("This line is printed by an example mod mixin from Fabric!");
// Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
// Constants.LOG.info("Classloader: {}", this.getClass().getClassLoader());
// }
//}
//public class FuelTank {
//}

View file

@ -16,7 +16,6 @@ import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.DebugPackets; import net.minecraft.network.protocol.game.DebugPackets;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -24,21 +23,20 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.ComparatorBlock;
import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.a71.tardim_ic.tardim_ic.Registration; import su.a71.tardim_ic.tardim_ic.Registration;
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBlock { public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBlock {
private boolean isPowered = false;
private Player lastPlayer = null;
public RedstoneInputBlock() { public RedstoneInputBlock() {
super(FabricBlockSettings.of(Material.METAL).strength(2, 4)); // No occlusion? super(FabricBlockSettings.of(Material.METAL).strength(2, 4)); // No occlusion?
} }
@ -56,10 +54,10 @@ public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBl
w.playSound(null, blockPos, TRDSounds.TARDIM_BEEP, SoundSource.BLOCKS, 0.3F, 0.5F); w.playSound(null, blockPos, TRDSounds.TARDIM_BEEP, SoundSource.BLOCKS, 0.3F, 0.5F);
BlockEntity be = w.getBlockEntity(blockPos); BlockEntity be = w.getBlockEntity(blockPos);
if (be instanceof TileEntityBaseTardimPanel && w.dimension() == TRDDimensions.TARDIS) { if (be instanceof RedstoneInputTileEntity && 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)) {
this.lastPlayer = player; ((RedstoneInputTileEntity) be).lastPlayer = player.getGameProfile().getId();
NetworkHandler.sendTo((ServerPlayer)player, new PacketOpenEditGui(blockPos, 1)); NetworkHandler.sendTo((ServerPlayer)player, new PacketOpenEditGui(blockPos, 1));
return InteractionResult.CONSUME; return InteractionResult.CONSUME;
} }
@ -80,22 +78,26 @@ public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBl
public void neighborChanged(BlockState blockState, Level level, BlockPos blockPos, Block block, BlockPos fromPos, boolean isMoving) { public void neighborChanged(BlockState blockState, Level level, BlockPos blockPos, Block block, BlockPos fromPos, boolean isMoving) {
DebugPackets.sendNeighborsUpdatePacket(level, blockPos); DebugPackets.sendNeighborsUpdatePacket(level, blockPos);
BlockEntity be = level.getBlockEntity(blockPos);
if (!(be instanceof RedstoneInputTileEntity)) {
return;
}
// get redstone signal // get redstone signal
Direction direction = blockState.getValue(FACING); Direction direction = blockState.getValue(FACING);
int redstoneSignal = level.getSignal(blockPos, direction); int redstoneSignal = level.getSignal(blockPos, direction);
if (redstoneSignal > 0 && !isPowered) { if (redstoneSignal > 0 && !((RedstoneInputTileEntity) be).isPowered) {
isPowered = true; ((RedstoneInputTileEntity) be).isPowered = true;
BlockEntity be = level.getBlockEntity(blockPos); if (level.dimension() == TRDDimensions.TARDIS) {
if (be instanceof TileEntityBaseTardimPanel && level.dimension() == TRDDimensions.TARDIS) {
TardimData data = TardimManager.getFromPos(blockPos); TardimData data = TardimManager.getFromPos(blockPos);
if (data != null && !level.isClientSide && this.lastPlayer != null) { if (data != null && !level.isClientSide && ((RedstoneInputTileEntity) be).lastPlayer != null) {
if (((TileEntityBaseTardimPanel)be).hasCommand()) { if (((TileEntityBaseTardimPanel)be).hasCommand()) {
((TileEntityBaseTardimPanel)be).execute(this.lastPlayer); ((TileEntityBaseTardimPanel)be).execute(new FakePlayer(level, blockPos, ((RedstoneInputTileEntity) be).lastPlayer));
} }
} }
} }
} else if (redstoneSignal == 0 && isPowered) } else if (redstoneSignal == 0 && ((RedstoneInputTileEntity) be).isPowered)
isPowered = false; ((RedstoneInputTileEntity) be).isPowered = false;
} }
} }

View file

@ -3,11 +3,17 @@ package su.a71.tardim_ic.tardim_ic.redstone_input;
import com.swdteam.tardim.tileentity.TileEntityBaseTardimPanel; import com.swdteam.tardim.tileentity.TileEntityBaseTardimPanel;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import su.a71.tardim_ic.tardim_ic.Registration; import su.a71.tardim_ic.tardim_ic.Registration;
import java.util.UUID;
public class RedstoneInputTileEntity extends TileEntityBaseTardimPanel { public class RedstoneInputTileEntity extends TileEntityBaseTardimPanel {
public boolean isPowered = false;
public UUID lastPlayer = null;
public RedstoneInputTileEntity(BlockPos pos, BlockState state) { public RedstoneInputTileEntity(BlockPos pos, BlockState state) {
super(Registration.REDSTONE_TARDIM_INPUT_TILEENTITY, pos, state); super(Registration.REDSTONE_TARDIM_INPUT_TILEENTITY, pos, state);
} }
@ -15,4 +21,21 @@ public class RedstoneInputTileEntity extends TileEntityBaseTardimPanel {
public BlockPos getPos() { public BlockPos getPos() {
return this.worldPosition; return this.worldPosition;
} }
@Override
public void saveAdditional(CompoundTag tag) {
tag.putBoolean("is_powered", isPowered);
if (lastPlayer != null) {
tag.putUUID("last_player", lastPlayer);
}
super.saveAdditional(tag);
}
@Override
public void load(CompoundTag tag) {
super.load(tag);
isPowered = tag.getBoolean("is_powered");
lastPlayer = tag.getUUID("last_player");
}
} }

View file

@ -0,0 +1,21 @@
package su.a71.tardim_ic.tardim_ic.tardim_dock;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
public class DockData {
public String name;
public BlockPos blockPos;
public Level level;
public boolean active = true;
public DockData(int id, Level level, BlockPos blockPos) {
this.level = level;
this.blockPos = blockPos;
this.name = DockManager.addDock(this);
}
public void setActive(boolean setting) {
this.active = setting;
}
}

View file

@ -0,0 +1,88 @@
package su.a71.tardim_ic.tardim_ic.tardim_dock;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.swdteam.tardim.main.Config;
import com.swdteam.tardim.main.Tardim;
import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager;
import com.swdteam.tardim.tardim.TardimSaveHandler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.storage.LevelResource;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
public class DockManager {
private static Map<String, DockData> DOCK_DATA = new HashMap<>();
Gson gson = new Gson();
public DockManager() {
}
public static DockData getDock(String name) {
return DOCK_DATA.get(name);
}
public static String addDock(DockData dockData) {
String new_id = Integer.toString(DOCK_DATA.size());
DOCK_DATA.put(new_id, dockData);
return new_id;
}
public void toggleActive(String name, boolean active) {
DockData dockData = DOCK_DATA.get(name);
dockData.setActive(active);
}
public void updateDock(String name, DockData dockData) {
DOCK_DATA.put(name, dockData);
}
public void load(MinecraftServer server) throws Exception {
File file = new File(server.getWorldPath(LevelResource.ROOT) + "/tardim_ic/dock_map.json");
// Check if file exists
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
FileWriter writer = new FileWriter(file);
writer.write(gson.toJson(new HashMap<Integer, DockData>()));
writer.close();
return;
}
Type typeOfDockMap = new TypeToken<Map<Integer, DockData>>() { }.getType();
JsonReader reader = new JsonReader(new FileReader(file));
String json = gson.fromJson(reader, String.class);
DOCK_DATA = gson.fromJson(json, typeOfDockMap);
System.out.println("Loaded TARDIM: IC docks");
}
public void save(MinecraftServer server) throws Exception {
File file = new File(server.getWorldPath(LevelResource.ROOT) + "/tardim_ic/dock_map.json");
// Check if file exists
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
Gson gson = new Gson();
String json = gson.toJson(DOCK_DATA);
JsonWriter writer = new JsonWriter(new FileWriter(file));
writer.jsonValue(json);
writer.close();
System.out.println("Saved TARDIM: IC docks");
}
}

View file

@ -35,15 +35,9 @@ import su.a71.tardim_ic.tardim_ic.Registration;
public class TardimDockBlock extends Block implements EntityBlock { public class TardimDockBlock extends Block implements EntityBlock {
public TardimDockBlock() { public TardimDockBlock() {
super(FabricBlockSettings.of(Material.METAL).strength(2, 4).noOcclusion()); // No occlusion? super(FabricBlockSettings.of(Material.METAL).strength(2, 4).noOcclusion());
} }
// @Nullable
// @Override
// public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
// return Registration.REDSTONE_TARDIM_INPUT_TILEENTITY.create(pos, state);
// }
@Override @Override
public InteractionResult use(BlockState blockState, Level w, BlockPos blockPos, Player player, InteractionHand hand, BlockHitResult p_60508_) { public InteractionResult use(BlockState blockState, Level w, BlockPos blockPos, Player player, InteractionHand hand, BlockHitResult p_60508_) {
if (!w.isClientSide) { if (!w.isClientSide) {

View file

@ -10,6 +10,7 @@ import su.a71.tardim_ic.tardim_ic.Registration;
public class TardimDockBlockEntity extends BlockEntity { public class TardimDockBlockEntity extends BlockEntity {
public int dock_id; public int dock_id;
public DockData data;
public TardimDockBlockEntity(BlockPos blockPos, BlockState blockState) { public TardimDockBlockEntity(BlockPos blockPos, BlockState blockState) {
super(Registration.TARDIM_DOCK_BLOCKENTITY, blockPos, blockState); super(Registration.TARDIM_DOCK_BLOCKENTITY, blockPos, blockState);

View file

@ -21,6 +21,9 @@
"su.a71.tardim_ic.tardim_ic.TardimInControl" "su.a71.tardim_ic.tardim_ic.TardimInControl"
] ]
}, },
"mixins": [
"tardim_ic.mixins.json"
],
"depends": { "depends": {
"fabricloader": ">=0.14.10", "fabricloader": ">=0.14.10",

View file

@ -0,0 +1,14 @@
"required": true,
"minVersion": "0.8",
"package": "su.a71.tardim_ic.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"FuelTank"
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -5,12 +5,14 @@ buildscript {
} }
dependencies { dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7.+'
} }
} }
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle' apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
archivesBaseName = "${mod_name}-forge-${minecraft_version}" archivesBaseName = "${mod_name}-forge-${minecraft_version}"
@ -70,6 +72,11 @@ minecraft {
} }
} }
mixin {
add sourceSets.main, 'refmap.tardim_ic.json'
config 'mixins.tardim_ic.json'
}
sourceSets.main.resources.srcDir 'src/generated/resources' sourceSets.main.resources.srcDir 'src/generated/resources'
dependencies { dependencies {
@ -78,6 +85,8 @@ dependencies {
implementation fg.deobf("curse.maven:tardim-531315:4453925") implementation fg.deobf("curse.maven:tardim-531315:4453925")
implementation fg.deobf("org.squiddev:cc-tweaked-1.19.1:${cc_version}") implementation fg.deobf("org.squiddev:cc-tweaked-1.19.1:${cc_version}")
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {

View file

@ -1,7 +1,9 @@
package su.a71.tardim_ic.tardim_ic; package su.a71.tardim_ic.tardim_ic;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.swdteam.common.command.tardim.ICommand; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
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.Item; import net.minecraft.world.item.Item;
@ -16,8 +18,9 @@ import net.minecraftforge.registries.RegistryObject;
import su.a71.tardim_ic.tardim_ic.digital_interface.DigitalInterfaceBlock; import su.a71.tardim_ic.tardim_ic.digital_interface.DigitalInterfaceBlock;
import su.a71.tardim_ic.tardim_ic.digital_interface.DigitalInterfaceTileEntity; import su.a71.tardim_ic.tardim_ic.digital_interface.DigitalInterfaceTileEntity;
import su.a71.tardim_ic.tardim_ic.redsone_input.RedstoneInputBlock; import su.a71.tardim_ic.tardim_ic.redstone_input.RedstoneInputBlock;
import su.a71.tardim_ic.tardim_ic.redsone_input.RedstoneInputTileEntity; import su.a71.tardim_ic.tardim_ic.redstone_input.RedstoneInputTileEntity;
import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -26,6 +29,7 @@ public class Registration {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, TardimInControl.MODID); public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, TardimInControl.MODID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TardimInControl.MODID); public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TardimInControl.MODID);
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, TardimInControl.MODID); public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, TardimInControl.MODID);
public static final DeferredRegister<SoundEvent> SOUNDS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, TardimInControl.MODID);
public static final CreativeModeTab TARDIM_IC_TAB = new CreativeModeTab("tardim_ic") { public static final CreativeModeTab TARDIM_IC_TAB = new CreativeModeTab("tardim_ic") {
@Override @Override
@ -47,11 +51,15 @@ public class Registration {
public static final RegistryObject<BlockEntityType<DigitalInterfaceTileEntity>> DIGITAL_TARDIM_INTERFACE_TILEENTITY = Registration.BLOCK_ENTITIES.register("digital_tardim_interface", () -> new BlockEntityType<>(DigitalInterfaceTileEntity::new, Sets.newHashSet(DIGITAL_TARDIM_INTERFACE.get()), null)); public static final RegistryObject<BlockEntityType<DigitalInterfaceTileEntity>> DIGITAL_TARDIM_INTERFACE_TILEENTITY = Registration.BLOCK_ENTITIES.register("digital_tardim_interface", () -> new BlockEntityType<>(DigitalInterfaceTileEntity::new, Sets.newHashSet(DIGITAL_TARDIM_INTERFACE.get()), null));
public static final RegistryObject<BlockEntityType<RedstoneInputTileEntity>> REDSTONE_TARDIM_INPUT_TILEENTITY = Registration.BLOCK_ENTITIES.register("redstone_tardim_input", () -> new BlockEntityType<>(RedstoneInputTileEntity::new, Sets.newHashSet(REDSTONE_TARDIM_INPUT.get()), null)); public static final RegistryObject<BlockEntityType<RedstoneInputTileEntity>> REDSTONE_TARDIM_INPUT_TILEENTITY = Registration.BLOCK_ENTITIES.register("redstone_tardim_input", () -> new BlockEntityType<>(RedstoneInputTileEntity::new, Sets.newHashSet(REDSTONE_TARDIM_INPUT.get()), null));
// Cloister bell
public static final RegistryObject<SoundEvent> CLOISTER_SOUND = SOUNDS.register("cloister", () -> new SoundEvent(new ResourceLocation(TardimInControl.MODID, "cloister")));
// Register our stuff // Register our stuff
public static void register() { public static void register() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
BLOCKS.register(modEventBus); BLOCKS.register(modEventBus);
ITEMS.register(modEventBus); ITEMS.register(modEventBus);
BLOCK_ENTITIES.register(modEventBus); BLOCK_ENTITIES.register(modEventBus);
SOUNDS.register(modEventBus);
} }
} }

View file

@ -4,6 +4,7 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import su.a71.tardim_ic.tardim_ic.registration.CommandInit; import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
import com.swdteam.tardim.TardimSaveHandler;
// The value here should match an entry in the META-INF/mods.toml file // The value here should match an entry in the META-INF/mods.toml file
@Mod(Constants.MOD_ID) @Mod(Constants.MOD_ID)
@ -14,7 +15,6 @@ public class TardimInControl {
public TardimInControl() { public TardimInControl() {
Registration.register(); Registration.register();
CommandInit.init(); // Register commands
// Register ourselves for server and other game events we are interested in. Currently, we do not use any events // Register ourselves for server and other game events we are interested in. Currently, we do not use any events
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);

View file

@ -13,9 +13,12 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
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 su.a71.tardim_ic.tardim_ic.Registration;
//import static com.swdteam.common.command.tardim.CommandTardimBase.sendResponse; //import static com.swdteam.common.command.tardim.CommandTardimBase.sendResponse;
public class CommandCloisterBell implements ICommand { public class CommandCloisterBell implements ICommand {
@Override @Override
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) { public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
@ -24,7 +27,17 @@ public class CommandCloisterBell implements ICommand {
if (data != null) { if (data != null) {
if (data.hasPermission(player)) { if (data.hasPermission(player)) {
try { try {
CommandTardimBase.sendResponse(player, "<Insert Cloister bell>", CommandTardimBase.ResponseType.COMPLETE, source); Level lvl = player.getLevel();
if (!lvl.isClientSide) {
lvl.playSound(
null,
pos,
Registration.CLOISTER_SOUND.get(),
SoundSource.BLOCKS,
1.5f,
1f
);
}
} 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);
} }
@ -39,12 +52,12 @@ public class CommandCloisterBell implements ICommand {
@Override @Override
public String getCommandName() { public String getCommandName() {
return "cloisterBell"; return "cloister-bell";
} }
@Override @Override
public String getUsage() { public String getUsage() {
return "cloisterBell"; return "/cloister-bell";
} }
@Override @Override

View file

@ -0,0 +1,17 @@
package su.a71.tardim_ic.tardim_ic.mixin;
import org.spongepowered.asm.mixin.Mixin;
import com.swdteam.common.init.CommandManager;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
@Mixin(value = CommandManager.class, remap = false)
public abstract class Commands {
@Inject(method="init()V", at=@At("TAIL"))
private static void init(CallbackInfo ci) {
CommandInit.init();
System.out.println("TARDIM: IC added commands using mixin");
}
}

View file

@ -0,0 +1,9 @@
package su.a71.tardim_ic.tardim_ic.mixin;
import com.swdteam.tileentity.TileEntityFuelStorage;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(TileEntityFuelStorage.class)
public abstract class FuelTank {
}

View file

@ -1,28 +0,0 @@
package su.a71.tardim_ic.tardim_ic.redsone_input;
import com.swdteam.tileentity.TileEntityBaseTardimPanel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import org.jetbrains.annotations.NotNull;
import com.swdteam.common.init.TRDTiles;
import su.a71.tardim_ic.tardim_ic.Registration;
import com.swdteam.tileentity.TileEntityTardimScanner;
import com.swdteam.common.block.BlockTardimScanner;
public class RedstoneInputTileEntity extends TileEntityBaseTardimPanel {
public RedstoneInputTileEntity(BlockPos pos, BlockState state) {
super(Registration.REDSTONE_TARDIM_INPUT_TILEENTITY.get(), pos, state);
}
public BlockPos getPos() {
return this.worldPosition;
}
}

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.redsone_input; package su.a71.tardim_ic.tardim_ic.redstone_input;
import com.swdteam.common.block.BlockBaseTardimPanel; import com.swdteam.common.block.BlockBaseTardimPanel;
import com.swdteam.common.init.TRDDimensions; import com.swdteam.common.init.TRDDimensions;
@ -29,16 +29,13 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.common.util.FakePlayerFactory; // TODO: ???
import net.minecraftforge.server.ServerLifecycleHooks;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import su.a71.tardim_ic.tardim_ic.Registration; import su.a71.tardim_ic.tardim_ic.Registration;
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBlock { public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBlock {
private boolean isPowered = false;
public RedstoneInputBlock() { public RedstoneInputBlock() {
super(Properties.of(Material.METAL).strength(2, 4).noOcclusion()); super(Properties.of(Material.METAL).strength(2, 4).noOcclusion());
} }
@ -59,6 +56,7 @@ public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBl
if (be instanceof TileEntityBaseTardimPanel && w.dimension() == TRDDimensions.TARDIS) { if (be instanceof TileEntityBaseTardimPanel && 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)) {
((RedstoneInputTileEntity) be).lastPlayer = player.getGameProfile().getId();
NetworkHandler.sendTo((ServerPlayer)player, new PacketOpenEditGui(1, blockPos)); NetworkHandler.sendTo((ServerPlayer)player, new PacketOpenEditGui(1, blockPos));
return InteractionResult.CONSUME; return InteractionResult.CONSUME;
} }
@ -79,22 +77,26 @@ public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBl
public void neighborChanged(BlockState blockState, Level level, BlockPos blockPos, Block block, BlockPos fromPos, boolean isMoving) { public void neighborChanged(BlockState blockState, Level level, BlockPos blockPos, Block block, BlockPos fromPos, boolean isMoving) {
DebugPackets.sendNeighborsUpdatePacket(level, blockPos); DebugPackets.sendNeighborsUpdatePacket(level, blockPos);
BlockEntity be = level.getBlockEntity(blockPos);
if (!(be instanceof RedstoneInputTileEntity)) {
return;
}
// get redstone signal // get redstone signal
Direction direction = blockState.getValue(FACING); Direction direction = blockState.getValue(FACING);
int redstoneSignal = level.getSignal(blockPos, direction); int redstoneSignal = level.getSignal(blockPos, direction);
if (redstoneSignal > 0 && !isPowered) { if (redstoneSignal > 0 && !((RedstoneInputTileEntity) be).isPowered) {
isPowered = true; ((RedstoneInputTileEntity) be).isPowered = true;
BlockEntity be = level.getBlockEntity(blockPos); if (level.dimension() == TRDDimensions.TARDIS) {
if (be instanceof TileEntityBaseTardimPanel && level.dimension() == TRDDimensions.TARDIS) {
TardimData data = TardimManager.getFromPos(blockPos); TardimData data = TardimManager.getFromPos(blockPos);
if (data != null) { if (data != null && !level.isClientSide && ((RedstoneInputTileEntity) be).lastPlayer != null) {
if (((TileEntityBaseTardimPanel)be).hasCommand()) { if (((TileEntityBaseTardimPanel)be).hasCommand()) {
((TileEntityBaseTardimPanel)be).execute(FakePlayerFactory.getMinecraft(ServerLifecycleHooks.getCurrentServer().getLevel(level.dimension()))); ((TileEntityBaseTardimPanel)be).execute(new FakePlayer(level, blockPos, ((RedstoneInputTileEntity) be).lastPlayer));
} }
} }
} }
} else if (redstoneSignal == 0 && isPowered) } else if (redstoneSignal == 0 && ((RedstoneInputTileEntity) be).isPowered)
isPowered = false; ((RedstoneInputTileEntity) be).isPowered = false;
} }
} }

View file

@ -0,0 +1,41 @@
package su.a71.tardim_ic.tardim_ic.redstone_input;
import com.swdteam.tileentity.TileEntityBaseTardimPanel;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.state.BlockState;
import su.a71.tardim_ic.tardim_ic.Registration;
import java.util.UUID;
public class RedstoneInputTileEntity extends TileEntityBaseTardimPanel {
public boolean isPowered = false;
public UUID lastPlayer = null;
public RedstoneInputTileEntity(BlockPos pos, BlockState state) {
super(Registration.REDSTONE_TARDIM_INPUT_TILEENTITY.get(), pos, state);
}
public BlockPos getPos() {
return this.worldPosition;
}
@Override
public void saveAdditional(CompoundTag tag) {
tag.putBoolean("is_powered", isPowered);
if (lastPlayer != null) {
tag.putUUID("last_player", lastPlayer);
}
super.saveAdditional(tag);
}
@Override
public void load(CompoundTag tag) {
super.load(tag);
isPowered = tag.getBoolean("is_powered");
lastPlayer = tag.getUUID("last_player");
}
}

View file

@ -8,6 +8,6 @@ import com.swdteam.common.init.CommandManager;
public class CommandInit { public class CommandInit {
public static void init() { public static void init() {
CommandManager.register(new CommandModemTransmit()); CommandManager.register(new CommandModemTransmit());
//CommandManager.register(new CommandCloisterBell()); CommandManager.register(new CommandCloisterBell());
} }
} }

View file

@ -0,0 +1,15 @@
{
"required": true,
"package": "su.a71.tardim_ic.tardim_ic.mixin",
"compatibilityLevel": "JAVA_17",
"refmap": "refmap.tardim_ic.json",
"mixins": [
"Commands"
],
"client": [
],
"injectors": {
"defaultRequire": 1
},
"minVersion": "0.8.4"
}

View file

@ -1,19 +1,15 @@
# TARDIM: In Control ![Modrinth Downloads](https://img.shields.io/modrinth/dt/tardim-in-control?color=00AF5C&label=modrinth&style=flat&logo=modrinth) # TARDIM: In Control ![Modrinth Downloads](https://img.shields.io/modrinth/dt/tardim-in-control?color=00AF5C&label=modrinth&style=flat&logo=modrinth)
### All of time and space, *now automated*. ### All of time and space, *now automated*.
This mod is an addon for the [TARDIM mod](https://modrinth.com/mod/tardim), and adds a way to control your time (but mostly space) machine with [ComputerCraft: Tweaked](https://tweaked.cc) computers and redstone using a new blocks and peripherals. ![Example dashboard](https://cdn.modrinth.com/data/xsv4H3pa/images/a6726a966b6ceb6cbfa81d4886b26375ee500854.png)
This mod is an addon for the [TARDIM mod](https://www.curseforge.com/minecraft/mc-mods/tardim), and adds a way to control your time (but mostly space) machine with [ComputerCraft: Tweaked](https://tweaked.cc) computers and redstone using new blocks and peripherals.
### Features: ### Features:
* Digital TARDIM interface: ComputerCraft peripheral that lets you control a TARDIM using CC methods! Full list of methods is available in the [Javadoc](http://andrey71.me/TARDIM-ic-docs/su/a71/tardim_ic/tardim_ic/DigitalInterfacePeripheral.html) (Sorry for that, this is the best auto-generated docs I could find for now). The peripheral supports almost all commands that the TARDIM computer panel has. * Digital TARDIM interface: ComputerCraft peripheral that lets you control a TARDIM using computers! Full list of methods is available in the [Javadoc](http://andrey71.me/TARDIM-ic-docs/su/a71/tardim_ic/tardim_ic/DigitalInterfacePeripheral.html) (Sorry for that, this is the best auto-generated docs I could find for now). The peripheral supports almost all commands that the TARDIM computer panel has.
* Redstone TARDIM Input: New control block that lets you execute a TARDIM command with the power of redstone! After saving a command, this block executes it every time it gets powered by redstone * Redstone TARDIM Input: New block that lets you execute a TARDIM command with the power of redstone! After saving a command, this block executes it every time it gets powered by redstone
* *This is just the beginning, there are more features to come!* * *This is just the beginning, there are more features to come!*
### Note
This is important, due to nature of the mod **anyone** inside your TARDIM with access to a computer and this mod's peripheral
will be able to run **any** methods. There is no fix that I know of (aside from disabling any commands except "getters" like fuel info), so if you want to have this on your server
and do not trust everyone not to steal your blue box, make sure there is some kind of plot claim mod. If there will be demand for it I can try adding a config option to disable all but "harmless" methods.\
And another thing: the method that sets destination dimension doesn't check if the dimension is valid, if you cannot land just change dimension to a valid one.
### Example use-cases ### Example use-cases
* Make a dashboard to monitor fuel levels, current location, and other information on a screen in a nice way. * Make a dashboard to monitor fuel levels, current location, and other information on a screen in a nice way.
* Get refined control over your TARDIM, such as saving and loading locations, or setting a destination in a GUI. * Get refined control over your TARDIM, such as saving and loading locations, or setting a destination in a GUI.
@ -21,17 +17,27 @@ And another thing: the method that sets destination dimension doesn't check if t
The possibilities are endless, the only limit is your imagination! (And coding skills) The possibilities are endless, the only limit is your imagination! (And coding skills)
### Note
Due to nature of the mod **anyone** inside your TARDIM with access to a computer and this mod's peripheral
will be able to run **any** methods. There is no fix that I know of (aside from disabling any commands except "getters" like fuel info), so if you want to use this mod on your server,
please don't let untrustworthy players anywhere near your computer.\
And another thing: the method that sets destination dimension can't check if the dimension is valid. If you cannot land just change dimension to a valid one like overworld or nether.
### FAQ ### FAQ
**Is this for Fabric or Forge?** **Is this for Fabric or Forge?**
: As a Fabric player who recognises Forge's large playerbase, I intend to support both major modloaders. : Both! As a Fabric player who recognises Forge's large playerbase, I support both major modloaders.
Right now, only Forge version is present. However, as of April 13th 2023, I started to port to multi-loader system and intend to have a Fabric version soon.
**Can I use this in my modpack?** **Can I use this in my modpack?**
: Sure, as long as you credit me and link to this page. : Sure, as long as you don't claim the mod as your own. A link to this mod's page would be appreciated too.
**Will there be a 1.19.3 version and beyond?** **Will there be a 1.19.3 version and beyond?**
: Yes, I will try my best to update to later versions as soon as **both** ComputerCraft: Tweaked and TARDIM receive stable versions for them. : Right now my focus on 1.19.2, but I will try my best to update to later versions as soon as this mod is fully stable.
**I don't know CC, will this always be a CC-only mod?** **I encountered a bug or have a suggestion. What do I do?**
: OK, fine, nobody actually asked that. But in case you did, good news: No! As you might've noticed, version 0.8 add a block that make it possible to integrate your TARDIM into good old redstone! Going forward, I plan to add some way to get redstone *output* from the TARDIM as well, and maybe even streamline things like the cloister bell for those who don't want to code their own implementations! : If you have a problem or suggestion, the best way to get them to me is through the project's Discord server.
**I don't know ComputerCraft, will this always be a CC-only mod?**
: Ok fine, nobody actually asked that. But in case you did, good news: No! The mod already adds things like Redstone TARDIM Input,
which let you integrate your TARDIM into good old redstone. Going forward,
I plan to add even more ways to control the TARDIM without computers for those who don't want to code their own implementation.