There's this mountain of pure diamond
This commit is contained in:
parent
faa15aee6b
commit
48d214a0ee
38 changed files with 814 additions and 293 deletions
15
CHANGELOG.txt
Normal file
15
CHANGELOG.txt
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
Added list-biomes and list-dimensions TARDIM commands + Corresponding ComputerCraft methods
|
||||||
|
This is a community-requested QOL feature that lets users scroll through available biomes and,
|
||||||
|
with lua methods, make advanced navigation dashboards even easier.
|
||||||
|
|
||||||
|
Computercraft compatibility improvements
|
||||||
|
Made ComputerCraft optional
|
||||||
|
Added peripherals for fuel storage, time rotor and scanner blocks
|
||||||
|
Added digital interface methods that list biomes and dimensions
|
||||||
|
|
||||||
|
Added Create compatibility
|
||||||
|
Added various display sources for fuel storage
|
||||||
|
|
||||||
|
Improved TARDIM's fuel system
|
||||||
|
Any item that can be used as fuel in furnace should now be able to power up a TARDIM
|
||||||
|
Buckets no longer get destroyed, and only get their fluids taken
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"facing=north": { "model": "tardim_ic:block/food_machine"},
|
||||||
|
"facing=east": { "model": "tardim_ic:block/food_machine", "y": 90},
|
||||||
|
"facing=south": { "model": "tardim_ic:block/food_machine", "y": 180},
|
||||||
|
"facing=west": { "model": "tardim_ic:block/food_machine", "y": 270}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 163 B |
Binary file not shown.
After Width: | Height: | Size: 216 B |
Binary file not shown.
After Width: | Height: | Size: 361 B |
Binary file not shown.
After Width: | Height: | Size: 248 B |
Binary file not shown.
After Width: | Height: | Size: 382 B |
|
@ -14,10 +14,11 @@ import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||||
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.fabric.api.item.v1.FabricItemSettings;
|
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||||
|
|
||||||
|
import su.a71.tardim_ic.tardim_ic.blocks.food_machine.FoodMachineBlock;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.blocks.food_machine.FoodMachineTileEntity;
|
||||||
import su.a71.tardim_ic.tardim_ic.jammer.LocationJammerMaterial;
|
import su.a71.tardim_ic.tardim_ic.jammer.LocationJammerMaterial;
|
||||||
import su.a71.tardim_ic.tardim_ic.redstone_input.RedstoneInputBlock;
|
import su.a71.tardim_ic.tardim_ic.blocks.redstone_input.RedstoneInputBlock;
|
||||||
import su.a71.tardim_ic.tardim_ic.redstone_input.RedstoneInputTileEntity;
|
import su.a71.tardim_ic.tardim_ic.blocks.redstone_input.RedstoneInputTileEntity;
|
||||||
import su.a71.tardim_ic.tardim_ic.Constants;
|
|
||||||
import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
|
import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
|
||||||
import su.a71.tardim_ic.tardim_ic.registration.ComputerCraftCompat;
|
import su.a71.tardim_ic.tardim_ic.registration.ComputerCraftCompat;
|
||||||
import su.a71.tardim_ic.tardim_ic.registration.CreateCompat;
|
import su.a71.tardim_ic.tardim_ic.registration.CreateCompat;
|
||||||
|
@ -26,6 +27,7 @@ import su.a71.tardim_ic.tardim_ic.registration.Exteriors;
|
||||||
public class Registration {
|
public class Registration {
|
||||||
// Blocks
|
// Blocks
|
||||||
public static final Block REDSTONE_TARDIM_INPUT = new RedstoneInputBlock();
|
public static final Block REDSTONE_TARDIM_INPUT = new RedstoneInputBlock();
|
||||||
|
public static final Block FOOD_MACHINE = new FoodMachineBlock();
|
||||||
|
|
||||||
// Tile Entities
|
// Tile Entities
|
||||||
public static final BlockEntityType<RedstoneInputTileEntity> REDSTONE_TARDIM_INPUT_TILEENTITY = Registry.register(
|
public static final BlockEntityType<RedstoneInputTileEntity> REDSTONE_TARDIM_INPUT_TILEENTITY = Registry.register(
|
||||||
|
@ -34,6 +36,12 @@ public class Registration {
|
||||||
FabricBlockEntityTypeBuilder.create(RedstoneInputTileEntity::new, REDSTONE_TARDIM_INPUT).build()
|
FabricBlockEntityTypeBuilder.create(RedstoneInputTileEntity::new, REDSTONE_TARDIM_INPUT).build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public static final BlockEntityType<FoodMachineTileEntity> FOOD_MACHINE_TILEENTITY = Registry.register(
|
||||||
|
Registry.BLOCK_ENTITY_TYPE,
|
||||||
|
new ResourceLocation("tardim_ic", "food_machine"),
|
||||||
|
FabricBlockEntityTypeBuilder.create(FoodMachineTileEntity::new, FOOD_MACHINE).build()
|
||||||
|
);
|
||||||
|
|
||||||
public static final CreativeModeTab TARDIM_IC_TAB = FabricItemGroupBuilder
|
public static final CreativeModeTab TARDIM_IC_TAB = FabricItemGroupBuilder
|
||||||
.create(new ResourceLocation("tardim_ic"))
|
.create(new ResourceLocation("tardim_ic"))
|
||||||
.icon(() -> new ItemStack(REDSTONE_TARDIM_INPUT))
|
.icon(() -> new ItemStack(REDSTONE_TARDIM_INPUT))
|
||||||
|
@ -61,6 +69,9 @@ public class Registration {
|
||||||
Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "redstone_tardim_input"), REDSTONE_TARDIM_INPUT);
|
Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "redstone_tardim_input"), REDSTONE_TARDIM_INPUT);
|
||||||
Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "redstone_tardim_input"), new BlockItem(REDSTONE_TARDIM_INPUT, new FabricItemSettings().tab(TARDIM_IC_TAB)));
|
Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "redstone_tardim_input"), new BlockItem(REDSTONE_TARDIM_INPUT, new FabricItemSettings().tab(TARDIM_IC_TAB)));
|
||||||
|
|
||||||
|
Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "food_machine"), FOOD_MACHINE);
|
||||||
|
Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "food_machine"), new BlockItem(FOOD_MACHINE, new FabricItemSettings().tab(TARDIM_IC_TAB)));
|
||||||
|
|
||||||
Registry.register(Registry.SOUND_EVENT, CLOISTER_SOUND, CLOISTER_SOUND_EVENT);
|
Registry.register(Registry.SOUND_EVENT, CLOISTER_SOUND, CLOISTER_SOUND_EVENT);
|
||||||
|
|
||||||
CommandInit.init();
|
CommandInit.init();
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.blocks.food_machine;
|
||||||
|
|
||||||
|
import com.swdteam.tardim.common.init.TRDDimensions;
|
||||||
|
import com.swdteam.tardim.common.init.TRDSounds;
|
||||||
|
import com.swdteam.tardim.network.NetworkHandler;
|
||||||
|
import com.swdteam.tardim.network.PacketOpenEditGui;
|
||||||
|
import com.swdteam.tardim.tardim.TardimData;
|
||||||
|
import com.swdteam.tardim.tardim.TardimManager;
|
||||||
|
import com.swdteam.tardim.tileentity.TileEntityBaseTardimPanel;
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.protocol.game.DebugPackets;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.InteractionResult;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.LevelReader;
|
||||||
|
import net.minecraft.world.level.block.*;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
|
import net.minecraft.world.level.material.Material;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.Registration;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.blocks.redstone_input.RedstoneInputTileEntity;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||||
|
|
||||||
|
public class FoodMachineBlock extends HorizontalDirectionalBlock implements EntityBlock {
|
||||||
|
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||||
|
|
||||||
|
public FoodMachineBlock() {
|
||||||
|
super(FabricBlockSettings.of(Material.METAL).strength(2, 4).noOcclusion()); // 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) {
|
||||||
|
return this.defaultBlockState().setValue(FACING, $$0.getHorizontalDirection().getOpposite());
|
||||||
|
}
|
||||||
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> $$0) {
|
||||||
|
$$0.add(FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
|
||||||
|
return Registration.FOOD_MACHINE_TILEENTITY.create(pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InteractionResult use(BlockState blockState, Level w, BlockPos blockPos, Player player, InteractionHand hand, BlockHitResult p_60508_) {
|
||||||
|
if (!w.isClientSide) {
|
||||||
|
w.playSound(null, blockPos, TRDSounds.TARDIM_BEEP, SoundSource.BLOCKS, 0.3F, 0.5F);
|
||||||
|
BlockEntity be = w.getBlockEntity(blockPos);
|
||||||
|
if (be instanceof FoodMachineTileEntity && 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
|
||||||
|
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 {
|
||||||
|
player.displayClientMessage(
|
||||||
|
Component.literal("You do not have enough fuel").withStyle(ChatFormatting.DARK_RED).withStyle(ChatFormatting.BOLD), true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return InteractionResult.CONSUME;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.displayClientMessage(
|
||||||
|
Component.literal("You do not have permission").withStyle(ChatFormatting.DARK_RED).withStyle(ChatFormatting.BOLD), true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return InteractionResult.CONSUME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canSurvive(BlockState blockState, LevelReader levelReader, BlockPos blockPos) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.blocks.food_machine;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.Registration;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class FoodMachineTileEntity extends BlockEntity {
|
||||||
|
public boolean isPowered = false;
|
||||||
|
public UUID lastPlayer = null;
|
||||||
|
|
||||||
|
public FoodMachineTileEntity(BlockPos pos, BlockState state) {
|
||||||
|
super(Registration.REDSTONE_TARDIM_INPUT_TILEENTITY, 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");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package su.a71.tardim_ic.tardim_ic.redstone_input;
|
package su.a71.tardim_ic.tardim_ic.blocks.redstone_input;
|
||||||
|
|
||||||
import com.swdteam.tardim.common.block.BlockBaseTardimPanel;
|
import com.swdteam.tardim.common.block.BlockBaseTardimPanel;
|
||||||
import com.swdteam.tardim.common.init.TRDDimensions;
|
import com.swdteam.tardim.common.init.TRDDimensions;
|
||||||
|
@ -99,4 +99,4 @@ public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBl
|
||||||
} else if (redstoneSignal == 0 && ((RedstoneInputTileEntity) be).isPowered)
|
} else if (redstoneSignal == 0 && ((RedstoneInputTileEntity) be).isPowered)
|
||||||
((RedstoneInputTileEntity) be).isPowered = false;
|
((RedstoneInputTileEntity) be).isPowered = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package su.a71.tardim_ic.tardim_ic.redstone_input;
|
package su.a71.tardim_ic.tardim_ic.blocks.redstone_input;
|
||||||
|
|
||||||
import com.swdteam.tardim.tileentity.TileEntityBaseTardimPanel;
|
import com.swdteam.tardim.tileentity.TileEntityBaseTardimPanel;
|
||||||
|
|
|
@ -12,6 +12,9 @@ import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
import su.a71.tardim_ic.tardim_ic.Registration;
|
import su.a71.tardim_ic.tardim_ic.Registration;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This command transmits the cloister bell sound in a big enough radius that you could hear it in any reasonably sized interior.
|
||||||
|
*/
|
||||||
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) {
|
||||||
|
|
|
@ -8,9 +8,16 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.inventory.FurnaceFuelSlot;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
This command prints list of all biomes into the console to find technical names
|
||||||
|
You can also pass an argument to search for entries with this string (e.g. amethyst for terralith:amethyst_rainforest
|
||||||
|
*/
|
||||||
public class CommandListBiomes implements ICommand{
|
public class CommandListBiomes 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) {
|
||||||
|
@ -23,7 +30,7 @@ public class CommandListBiomes implements ICommand{
|
||||||
biomeRegistry.keySet().forEach(
|
biomeRegistry.keySet().forEach(
|
||||||
(ResourceLocation res) -> {
|
(ResourceLocation res) -> {
|
||||||
String out = res.toString();
|
String out = res.toString();
|
||||||
if (args.length == 0 || (args[0].equals(out.split(":")[0]))) {
|
if (args.length == 0 || out.toLowerCase().contains(args[0].toLowerCase())) {
|
||||||
CommandTardimBase.sendResponse(player, out, CommandTardimBase.ResponseType.INFO, source);
|
CommandTardimBase.sendResponse(player, out, CommandTardimBase.ResponseType.INFO, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +51,7 @@ public class CommandListBiomes implements ICommand{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "/list-biomes";
|
return "/list-biomes <..search_query>"; // TODO: how to communicate this better
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,6 +8,9 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This command prints list of all dimensions into the console to find technical names
|
||||||
|
*/
|
||||||
public class CommandListDimensions implements ICommand{
|
public class CommandListDimensions 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) {
|
||||||
|
@ -15,7 +18,6 @@ public class CommandListDimensions implements ICommand{
|
||||||
TardimData data = TardimManager.getFromPos(pos);
|
TardimData data = TardimManager.getFromPos(pos);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
if (data.hasPermission(player)) {
|
if (data.hasPermission(player)) {
|
||||||
// TODO: Does this really work?
|
|
||||||
for (ServerLevel serverLevel : player.getLevel().getServer().getAllLevels()) {
|
for (ServerLevel serverLevel : player.getLevel().getServer().getAllLevels()) {
|
||||||
CommandTardimBase.sendResponse(player, serverLevel.dimension().location().toString(), CommandTardimBase.ResponseType.INFO, source);
|
CommandTardimBase.sendResponse(player, serverLevel.dimension().location().toString(), CommandTardimBase.ResponseType.INFO, source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@ import dan200.computercraft.api.network.Packet;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This command sends out a ComputerCraft modem signal
|
||||||
|
This could be useful for connecting advanced navigation systems into "vanilla" controls
|
||||||
|
You can specify both channels, message and even make the message go across dimensions
|
||||||
|
*/
|
||||||
public class CommandModemTransmit implements ICommand {
|
public class CommandModemTransmit 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) {
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
package su.a71.tardim_ic.tardim_ic.digital_interface;
|
package su.a71.tardim_ic.tardim_ic.computercraft_compat;
|
||||||
|
|
||||||
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.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
public class FakeDigitalInterfaceTileEntity implements IDigitalInterfaceEntity {
|
public class FakeTardimPeripheralTileEntity implements ITardimPeripheralTileEntity {
|
||||||
public BlockPos blockPos;
|
public BlockPos blockPos;
|
||||||
public Level level;
|
public Level level;
|
||||||
public TardimData data; // Our TARDIM
|
public TardimData data; // Our TARDIM
|
||||||
|
|
||||||
|
|
||||||
FakeDigitalInterfaceTileEntity(BlockPos in_block, Level in_level) {
|
public FakeTardimPeripheralTileEntity(BlockPos in_block, Level in_level) {
|
||||||
this.blockPos = in_block;
|
this.blockPos = in_block;
|
||||||
this.level = in_level;
|
this.level = in_level;
|
||||||
this.data = getTardimDataInitial();
|
this.data = getTardimDataInitial();
|
|
@ -0,0 +1,14 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.computercraft_compat;
|
||||||
|
|
||||||
|
import com.swdteam.tardim.tardim.TardimData;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
|
// This is used to getPost(), getLevel() and getTardim() nicely without refactoring code to account for PeripheralProvider
|
||||||
|
// At least I believe so. Otherwise don't really remember why I don't just pass these methods to the peripherals.
|
||||||
|
public interface ITardimPeripheralTileEntity {
|
||||||
|
public BlockPos getPos();
|
||||||
|
public Level getLevel();
|
||||||
|
|
||||||
|
public TardimData getTardim();
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.computercraft_compat;
|
||||||
|
|
||||||
|
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.IPeripheral;
|
||||||
|
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals.FuelStoragePeripheral;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals.TardimScannerPeripheral;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals.TimeRotorPeripheral;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.blocks.digital_interface.DigitalInterfaceBlock;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals.DigitalInterfacePeripheral;
|
||||||
|
|
||||||
|
public class TardimPeripheralProvider implements IPeripheralProvider {
|
||||||
|
@Override
|
||||||
|
public IPeripheral getPeripheral(@NotNull Level level, @NotNull BlockPos blockPos, @NotNull Direction direction) {
|
||||||
|
if (level.isClientSide()) return null; // Please...?
|
||||||
|
|
||||||
|
Block block = level.getBlockState(blockPos).getBlock();
|
||||||
|
if (block instanceof DigitalInterfaceBlock) {
|
||||||
|
return new DigitalInterfacePeripheral(new FakeTardimPeripheralTileEntity(blockPos, level));
|
||||||
|
} else if (block instanceof BlockFuelStorage) {
|
||||||
|
return new FuelStoragePeripheral(new FakeTardimPeripheralTileEntity(blockPos, level));
|
||||||
|
} else if (block instanceof BlockRotor) {
|
||||||
|
return new TimeRotorPeripheral(new FakeTardimPeripheralTileEntity(blockPos, level));
|
||||||
|
} else if (block instanceof BlockTardimScanner) {
|
||||||
|
return new TardimScannerPeripheral(new FakeTardimPeripheralTileEntity(blockPos, level));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package su.a71.tardim_ic.tardim_ic.digital_interface;
|
package su.a71.tardim_ic.tardim_ic.computercraft_compat.blocks.digital_interface;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
|
@ -0,0 +1,14 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.computercraft_compat.blocks.digital_interface;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
import su.a71.tardim_ic.tardim_ic.registration.ComputerCraftCompat;
|
||||||
|
|
||||||
|
|
||||||
|
public class DigitalInterfaceTileEntity extends BlockEntity {//implements IDigitalInterfaceEntity {
|
||||||
|
public DigitalInterfaceTileEntity(BlockPos pos, BlockState state) {
|
||||||
|
super(ComputerCraftCompat.DIGITAL_TARDIM_INTERFACE_TILEENTITY, pos, state);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package su.a71.tardim_ic.tardim_ic.digital_interface;
|
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
|
||||||
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
|
||||||
import com.swdteam.tardim.common.command.tardim.CommandTravel;
|
import com.swdteam.tardim.common.command.tardim.CommandTravel;
|
||||||
import com.swdteam.tardim.common.data.DimensionMapReloadListener;
|
import com.swdteam.tardim.common.data.DimensionMapReloadListener;
|
||||||
import com.swdteam.tardim.common.init.TRDSounds;
|
import com.swdteam.tardim.common.init.TRDSounds;
|
||||||
|
@ -14,8 +13,9 @@ import com.swdteam.tardim.tardim.TardimManager;
|
||||||
import dan200.computercraft.api.lua.LuaException;
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
import dan200.computercraft.api.lua.LuaFunction;
|
import dan200.computercraft.api.lua.LuaFunction;
|
||||||
import dan200.computercraft.api.lua.ObjectLuaTable;
|
import dan200.computercraft.api.lua.ObjectLuaTable;
|
||||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
|
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
|
@ -33,27 +33,23 @@ import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.levelgen.Heightmap;
|
import net.minecraft.world.level.levelgen.Heightmap;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.squiddev.cobalt.Lua;
|
|
||||||
import su.a71.tardim_ic.tardim_ic.Registration;
|
import su.a71.tardim_ic.tardim_ic.Registration;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.FakeTardimPeripheralTileEntity;
|
||||||
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
|
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static su.a71.tardim_ic.tardim_ic.Registration.LOCATION_JAMMER;
|
import static su.a71.tardim_ic.tardim_ic.Registration.LOCATION_JAMMER;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class DigitalInterfacePeripheral implements IPeripheral {
|
|
||||||
|
|
||||||
private final List<IComputerAccess> connectedComputers = new ArrayList<>(); // List of computers connected to the peripheral
|
public class DigitalInterfacePeripheral extends TardimPeripheral implements IPeripheral {
|
||||||
private final IDigitalInterfaceEntity tileEntity; // Peripheral's BlockEntity, used for accessing coordinates
|
|
||||||
/**
|
/**
|
||||||
* @param tileEntity the tile entity of this peripheral
|
* @param tileEntity the tile entity of this peripheral
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
public DigitalInterfacePeripheral(IDigitalInterfaceEntity tileEntity) {
|
public DigitalInterfacePeripheral(FakeTardimPeripheralTileEntity tileEntity) {
|
||||||
this.tileEntity = tileEntity;
|
super(tileEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Setting name for the peripheral. A computer will see it as "digital_tardim_interface_n"
|
/** Setting name for the peripheral. A computer will see it as "digital_tardim_interface_n"
|
||||||
|
@ -63,118 +59,6 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
||||||
@Override
|
@Override
|
||||||
public String getType() { return "digital_tardim_interface"; }
|
public String getType() { return "digital_tardim_interface"; }
|
||||||
|
|
||||||
/** Apparently CC uses this to check if the peripheral in front of a modem is this one
|
|
||||||
* @hidden
|
|
||||||
* @param iPeripheral The peripheral to compare against. This may be {@code null}.
|
|
||||||
* @return {@code true} if the peripheral is the same as this one.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean equals(@Nullable IPeripheral iPeripheral) { return this == iPeripheral; }
|
|
||||||
|
|
||||||
/** Called when a computer disconnects from the peripheral
|
|
||||||
* @hidden
|
|
||||||
* @param computer The interface to the computer that is being detached. Remember that multiple computers can be
|
|
||||||
* attached to a peripheral at once.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void detach(@Nonnull IComputerAccess computer) { connectedComputers.remove(computer); }
|
|
||||||
|
|
||||||
/** Called when a computer connects to the peripheral
|
|
||||||
* @hidden
|
|
||||||
* @param computer The interface to the computer that is being attached. Remember that multiple computers can be
|
|
||||||
* attached to a peripheral at once.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void attach(@Nonnull IComputerAccess computer) { connectedComputers.add(computer); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* I *think* I use this to get peripheral's world position
|
|
||||||
* @hidden
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public IDigitalInterfaceEntity getTileEntity() {
|
|
||||||
return tileEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get TARDIM's data, which we need for *every* function
|
|
||||||
* <p>
|
|
||||||
* We can't do a simple
|
|
||||||
* <code>TardimManager.getFromPos(getTileEntity().getPos())</code>
|
|
||||||
* <p>
|
|
||||||
* because if someone attempts to call a method outside a TARDIM, this would create a new TARDIM/Point to the one with ID of 0 (Due to the way TardimSaveHandler.loadTardisData works).
|
|
||||||
* Which is obviously not what we want.
|
|
||||||
* <p>
|
|
||||||
* So instead we use this, and get the ability to give user a LuaException if they think that fiddling with time is funny
|
|
||||||
* This is mostly a copy of getIDForXZ function with some added checks
|
|
||||||
*
|
|
||||||
* @return TardimData of the TARDIM that the peripheral is in
|
|
||||||
* @hidden
|
|
||||||
*/
|
|
||||||
public TardimData getTardimDataInitial() {
|
|
||||||
int X = getTileEntity().getPos().getX(), Z = getTileEntity().getPos().getZ();
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
int x = 0;
|
|
||||||
int y = 0;
|
|
||||||
int dx = 0;
|
|
||||||
int dy = 1;
|
|
||||||
int segment_length = 1;
|
|
||||||
int segment_passed = 0;
|
|
||||||
boolean found = false;
|
|
||||||
long timecheck = System.currentTimeMillis();
|
|
||||||
|
|
||||||
while(true) {
|
|
||||||
if (System.currentTimeMillis() - timecheck > 10000L) {
|
|
||||||
System.out.println("Finding ID from XZ Coordinates is taking too long!");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (X >= x * TardimManager.INTERIOR_BOUNDS
|
|
||||||
&& X <= TardimManager.INTERIOR_BOUNDS + x * TardimManager.INTERIOR_BOUNDS
|
|
||||||
&& Z >= y * TardimManager.INTERIOR_BOUNDS
|
|
||||||
&& Z <= TardimManager.INTERIOR_BOUNDS + y * TardimManager.INTERIOR_BOUNDS) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
x += dx;
|
|
||||||
y += dy;
|
|
||||||
if (++segment_passed == segment_length) {
|
|
||||||
segment_passed = 0;
|
|
||||||
int buffer = dy;
|
|
||||||
dy = -dx;
|
|
||||||
dx = buffer;
|
|
||||||
if (buffer == 0) {
|
|
||||||
++segment_length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
++index;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We really don't want to access a ghost TARDIM, do we?
|
|
||||||
// If we fail checks here are not inside a TARDIM
|
|
||||||
if (!found) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
TardimData T = TardimManager.getTardim(index);
|
|
||||||
if (T.getCurrentLocation() == null || T.getOwnerName() == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return T;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TardimData getTardimData() throws LuaException {
|
|
||||||
TardimData data = this.getTileEntity().getTardim();
|
|
||||||
if (data == null || data.getCurrentLocation() == null || data.getOwnerName() == null) {
|
|
||||||
throw new LuaException("Peripheral is not inside a TARDIM");
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Peripheral methods ===============================================================
|
// Peripheral methods ===============================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -397,7 +281,7 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
||||||
*/
|
*/
|
||||||
@LuaFunction(mainThread = true)
|
@LuaFunction(mainThread = true)
|
||||||
public final void home() throws LuaException {
|
public final void home() throws LuaException {
|
||||||
if (this.tileEntity.getLevel().isClientSide()) {
|
if (this.getTileEntity().getLevel().isClientSide()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TardimData data = getTardimData();
|
TardimData data = getTardimData();
|
||||||
|
@ -408,7 +292,7 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
||||||
throw new LuaException("TARDIM has no owner");
|
throw new LuaException("TARDIM has no owner");
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerList playerList = this.tileEntity.getLevel().getServer().getPlayerList();
|
PlayerList playerList = this.getTileEntity().getLevel().getServer().getPlayerList();
|
||||||
ServerPlayer player = playerList.getPlayer(uuid);
|
ServerPlayer player = playerList.getPlayer(uuid);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
throw new LuaException("TARDIM owner is not online");
|
throw new LuaException("TARDIM owner is not online");
|
||||||
|
@ -430,11 +314,11 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
||||||
*/
|
*/
|
||||||
@LuaFunction(mainThread = true)
|
@LuaFunction(mainThread = true)
|
||||||
public final void locatePlayer(String username) throws LuaException {
|
public final void locatePlayer(String username) throws LuaException {
|
||||||
if (this.tileEntity.getLevel().isClientSide()) {
|
if (this.getTileEntity().getLevel().isClientSide()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerList playerList = this.tileEntity.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) {
|
||||||
|
@ -461,11 +345,11 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
||||||
*/
|
*/
|
||||||
@LuaFunction(mainThread = true)
|
@LuaFunction(mainThread = true)
|
||||||
public final ObjectLuaTable getOnlinePlayers() throws LuaException {
|
public final ObjectLuaTable getOnlinePlayers() throws LuaException {
|
||||||
if (this.tileEntity.getLevel().isClientSide()) {
|
if (this.getTileEntity().getLevel().isClientSide()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerList playerList = this.tileEntity.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());
|
|
@ -0,0 +1,73 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
|
||||||
|
|
||||||
|
import com.swdteam.tardim.tardim.TardimData;
|
||||||
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
|
import dan200.computercraft.api.lua.LuaFunction;
|
||||||
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.FakeTardimPeripheralTileEntity;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CC Peripheral for TARDIM's fuel storage block.
|
||||||
|
* Only provides getters for the fuel parts for people who cannot afford or don't need the digital interface.
|
||||||
|
*/
|
||||||
|
public class FuelStoragePeripheral extends TardimPeripheral implements IPeripheral {
|
||||||
|
/**
|
||||||
|
* @param tileEntity the tile entity of this peripheral
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
public FuelStoragePeripheral(FakeTardimPeripheralTileEntity tileEntity) {
|
||||||
|
super(tileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Setting name for the peripheral. A computer will see it as "digital_tardim_interface_n"
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public String getType() { return "tardim_fuel_storage"; }
|
||||||
|
|
||||||
|
|
||||||
|
// Peripheral methods ===============================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return how much fuel is left in the TARDIM
|
||||||
|
*
|
||||||
|
* @return Fuel left (Out of 100)
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final double getFuel() throws LuaException {
|
||||||
|
return getTardimData().getFuel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get how much fuel it would take to travel to the destination
|
||||||
|
* @return Amount of fuel needed (Out of 100)
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final double calculateFuelForJourney() throws LuaException {
|
||||||
|
TardimData data = getTardimData();
|
||||||
|
|
||||||
|
if (data.getTravelLocation() == null) return 0;
|
||||||
|
|
||||||
|
TardimData.Location curr = data.getCurrentLocation();
|
||||||
|
TardimData.Location dest = data.getTravelLocation();
|
||||||
|
|
||||||
|
double fuel = 0.0;
|
||||||
|
|
||||||
|
if (curr.getLevel() != dest.getLevel())
|
||||||
|
{
|
||||||
|
fuel = 10.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3 posA = new Vec3(curr.getPos().getX(), curr.getPos().getY(), curr.getPos().getZ());
|
||||||
|
Vec3 posB = new Vec3(dest.getPos().getX(), dest.getPos().getY(), dest.getPos().getZ());
|
||||||
|
fuel += posA.distanceTo(posB) / 100.0;
|
||||||
|
if (fuel > 100.0) fuel = 100.0;
|
||||||
|
|
||||||
|
return fuel;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
|
||||||
|
|
||||||
|
import com.swdteam.tardim.tardim.TardimData;
|
||||||
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
|
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||||
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.ITardimPeripheralTileEntity;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
// Base CC peripheral for whn you need something with access to a TARDIM
|
||||||
|
public abstract class TardimPeripheral implements IPeripheral {
|
||||||
|
|
||||||
|
private final List<IComputerAccess> connectedComputers = new ArrayList<>(); // List of computers connected to the peripheral
|
||||||
|
public final ITardimPeripheralTileEntity tileEntity; // Peripheral's BlockEntity, used for accessing coordinates
|
||||||
|
/**
|
||||||
|
* @param tileEntity the tile entity of this peripheral
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
public TardimPeripheral(ITardimPeripheralTileEntity tileEntity) {
|
||||||
|
this.tileEntity = tileEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Apparently CC uses this to check if the peripheral in front of a modem is this one
|
||||||
|
* @hidden
|
||||||
|
* @param iPeripheral The peripheral to compare against. This may be {@code null}.
|
||||||
|
* @return {@code true} if the peripheral is the same as this one.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean equals(@Nullable IPeripheral iPeripheral) { return this == iPeripheral; }
|
||||||
|
|
||||||
|
/** Called when a computer disconnects from the peripheral
|
||||||
|
* @hidden
|
||||||
|
* @param computer The interface to the computer that is being detached. Remember that multiple computers can be
|
||||||
|
* attached to a peripheral at once.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void detach(@Nonnull IComputerAccess computer) { connectedComputers.remove(computer); }
|
||||||
|
|
||||||
|
/** Called when a computer connects to the peripheral
|
||||||
|
* @hidden
|
||||||
|
* @param computer The interface to the computer that is being attached. Remember that multiple computers can be
|
||||||
|
* attached to a peripheral at once.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void attach(@Nonnull IComputerAccess computer) { connectedComputers.add(computer); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I *think* I use this to get peripheral's world position
|
||||||
|
* @hidden
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ITardimPeripheralTileEntity getTileEntity() {
|
||||||
|
return tileEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public TardimData getTardimData() throws LuaException {
|
||||||
|
TardimData data = this.getTileEntity().getTardim();
|
||||||
|
if (data == null || data.getCurrentLocation() == null || data.getOwnerName() == null) {
|
||||||
|
throw new LuaException("Peripheral is not inside a TARDIM");
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,150 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
|
||||||
|
|
||||||
|
import com.swdteam.tardim.common.init.TardimRegistry;
|
||||||
|
import com.swdteam.tardim.tardim.TardimData;
|
||||||
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
|
import dan200.computercraft.api.lua.LuaFunction;
|
||||||
|
import dan200.computercraft.api.lua.ObjectLuaTable;
|
||||||
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.players.PlayerList;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.FakeTardimPeripheralTileEntity;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CC Peripheral for TARDIM's scanner block.
|
||||||
|
* Only provides getters for data-related (mostly table output) methods e.g. biome or companion list
|
||||||
|
* for people who cannot afford or don't need the digital interface.
|
||||||
|
*/
|
||||||
|
public class TardimScannerPeripheral extends TardimPeripheral implements IPeripheral {
|
||||||
|
/**
|
||||||
|
* @param tileEntity the tile entity of this peripheral
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
public TardimScannerPeripheral(FakeTardimPeripheralTileEntity tileEntity) {
|
||||||
|
super(tileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Setting name for the peripheral. A computer will see it as "digital_tardim_interface_n"
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public String getType() { return "tardim_scanner"; }
|
||||||
|
|
||||||
|
|
||||||
|
// Peripheral methods ===============================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get username of the TARDIM's owner
|
||||||
|
* @return String of the owner's username
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final String getOwnerName() throws LuaException {
|
||||||
|
TardimData data = getTardimData();
|
||||||
|
return data.getOwnerName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of the TARDIM owner's companions
|
||||||
|
* @return ObjectLuaTable containing the usernames of the companions
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final ObjectLuaTable getCompanions() throws LuaException {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get online players. Useful for making a GUI for the locate function or just a nice dashboard.
|
||||||
|
*
|
||||||
|
* @return ObjectLuaTable of the online players
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final ObjectLuaTable getOnlinePlayers() throws LuaException {
|
||||||
|
if (this.tileEntity.getLevel().isClientSide()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerList playerList = this.tileEntity.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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all available TARDIM skins. Useful for making a GUI skin selection.
|
||||||
|
*
|
||||||
|
* @return ObjectLuaTable of the available skins
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final ObjectLuaTable getSkins() throws LuaException {
|
||||||
|
if (this.getTileEntity().getLevel().isClientSide()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, String> skins = new HashMap<>();
|
||||||
|
|
||||||
|
Iterator var5 = TardimRegistry.getRegistry().keySet().iterator();
|
||||||
|
int i = 0;
|
||||||
|
while(var5.hasNext()) {
|
||||||
|
ResourceLocation builder = (ResourceLocation)var5.next();
|
||||||
|
TardimRegistry.TardimBuilder b = TardimRegistry.getTardimBuilder(builder);
|
||||||
|
skins.put(i + 1, b.getDisplayName());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ObjectLuaTable(skins);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a table with all registered biomes' names.
|
||||||
|
* Useful for creating advanced navigation systems.
|
||||||
|
* @return ObjectLuaTable with all biomes' technical names
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final ObjectLuaTable getBiomes() throws LuaException {
|
||||||
|
Map<Integer, String> biomes = new HashMap<>();
|
||||||
|
Registry<Biome> biomeRegistry = tileEntity.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
|
||||||
|
Iterator<ResourceLocation> biome_it = biomeRegistry.keySet().iterator();
|
||||||
|
int i = 0;
|
||||||
|
while (biome_it.hasNext()) {
|
||||||
|
biomes.put(i + 1, biome_it.next().toString());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ObjectLuaTable(biomes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a table with all registered dimensions' names.
|
||||||
|
* Useful for creating advanced navigation systems.
|
||||||
|
* @return ObjectLuaTable with all dimensions' technical names
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final ObjectLuaTable getDimensions() throws LuaException {
|
||||||
|
Iterator<ServerLevel> dim_it = this.getTileEntity().getLevel().getServer().getAllLevels().iterator(); // TODO: Does this really work?
|
||||||
|
Map<Integer, String> dimensions = new HashMap<>();
|
||||||
|
int i = 0;
|
||||||
|
while (dim_it.hasNext()) {
|
||||||
|
dimensions.put(i + 1, dim_it.next().dimension().location().toString());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return new ObjectLuaTable(dimensions);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,107 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
|
||||||
|
|
||||||
|
import com.swdteam.tardim.tardim.TardimData;
|
||||||
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
|
import dan200.computercraft.api.lua.LuaFunction;
|
||||||
|
import dan200.computercraft.api.lua.ObjectLuaTable;
|
||||||
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.FakeTardimPeripheralTileEntity;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CC Peripheral for TARDIM's time rotor block.
|
||||||
|
* Only provides getters for the flight status for people who cannot afford or don't need the digital interface.
|
||||||
|
*/
|
||||||
|
public class TimeRotorPeripheral extends TardimPeripheral implements IPeripheral {
|
||||||
|
/**
|
||||||
|
* @param tileEntity the tile entity of this peripheral
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
public TimeRotorPeripheral(FakeTardimPeripheralTileEntity tileEntity) {
|
||||||
|
super(tileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Setting name for the peripheral. A computer will see it as "digital_tardim_interface_n"
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public String getType() { return "tardim_time_rotor"; }
|
||||||
|
|
||||||
|
|
||||||
|
// Peripheral methods ===============================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the TARDIM is in flight
|
||||||
|
* @return true if in flight, false if not
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final boolean isInFlight() throws LuaException { return getTardimData().isInFlight(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supposedly gets UNIX timestamp of when we entered flight
|
||||||
|
* @return UNIX timestamp if in flight, -1 if not
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final long getTimeEnteredFlight() throws LuaException {
|
||||||
|
TardimData data = getTardimData();
|
||||||
|
if (!data.isInFlight()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return data.getTimeEnteredFlight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current location of the TARDIM
|
||||||
|
* @return ObjectLuaTable of the current location with the following keys:
|
||||||
|
* <ul>
|
||||||
|
* <li>dimension - String of the dimension</li>
|
||||||
|
* <li>pos - table with the keys x, y, z that hold numbers</li>
|
||||||
|
* <li>facing - String of the facing</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final ObjectLuaTable getCurrentLocation() throws LuaException {
|
||||||
|
TardimData.Location loc = getTardimData().getCurrentLocation();
|
||||||
|
return new ObjectLuaTable(Map.of(
|
||||||
|
"dimension", loc.getLevel().location().toString(),
|
||||||
|
"pos", new ObjectLuaTable(Map.of(
|
||||||
|
"x", loc.getPos().getX(),
|
||||||
|
"y", loc.getPos().getY(),
|
||||||
|
"z", loc.getPos().getZ()
|
||||||
|
)),
|
||||||
|
"facing", loc.getFacing().toString()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current location of the TARDIM
|
||||||
|
* @return if there is no destination returns null.
|
||||||
|
* <p>
|
||||||
|
* Otherwise, ObjectLuaTable of the current location with the following keys:
|
||||||
|
* <ul>
|
||||||
|
* <li>dimension - String of the dimension</li>
|
||||||
|
* <li>pos - table with the keys x, y, z that hold numbers</li>
|
||||||
|
* <li>facing - String of the facing</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final ObjectLuaTable getTravelLocation() throws LuaException {
|
||||||
|
TardimData data = getTardimData();
|
||||||
|
if (data.getTravelLocation() == null) {
|
||||||
|
data.setTravelLocation(data.getCurrentLocation());
|
||||||
|
}
|
||||||
|
TardimData.Location loc = data.getTravelLocation();
|
||||||
|
return new ObjectLuaTable(Map.of(
|
||||||
|
"dimension", loc.getLevel().location().toString(),
|
||||||
|
"pos", new ObjectLuaTable(Map.of(
|
||||||
|
"x", loc.getPos().getX(),
|
||||||
|
"y", loc.getPos().getY(),
|
||||||
|
"z", loc.getPos().getZ()
|
||||||
|
)),
|
||||||
|
"facing", loc.getFacing().toString()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,22 +0,0 @@
|
||||||
package su.a71.tardim_ic.tardim_ic.digital_interface;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class DigitalInterfacePeripheralProvider implements IPeripheralProvider {
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public IPeripheral getPeripheral(@NotNull Level level, @NotNull BlockPos blockPos, @NotNull Direction direction) {
|
|
||||||
if (level.isClientSide()) return null; // Please...?
|
|
||||||
if (level.getBlockState(blockPos).getBlock() instanceof DigitalInterfaceBlock) {
|
|
||||||
return new DigitalInterfacePeripheral(new FakeDigitalInterfaceTileEntity(blockPos, level));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,97 +0,0 @@
|
||||||
package su.a71.tardim_ic.tardim_ic.digital_interface;
|
|
||||||
|
|
||||||
import com.swdteam.tardim.tardim.TardimData;
|
|
||||||
import com.swdteam.tardim.tardim.TardimManager;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
|
|
||||||
import su.a71.tardim_ic.tardim_ic.Registration;
|
|
||||||
import su.a71.tardim_ic.tardim_ic.registration.ComputerCraftCompat;
|
|
||||||
|
|
||||||
|
|
||||||
public class DigitalInterfaceTileEntity extends BlockEntity {//implements IDigitalInterfaceEntity {
|
|
||||||
//public TardimData data; // Our TARDIM
|
|
||||||
|
|
||||||
|
|
||||||
public DigitalInterfaceTileEntity(BlockPos pos, BlockState state) {
|
|
||||||
super(ComputerCraftCompat.DIGITAL_TARDIM_INTERFACE_TILEENTITY, pos, state);
|
|
||||||
//this.data = getTardimDataInitial();
|
|
||||||
}
|
|
||||||
|
|
||||||
// public BlockPos getPos() {
|
|
||||||
// return this.worldPosition;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public TardimData getTardim() {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * The peripheral
|
|
||||||
// */
|
|
||||||
// protected DigitalInterfacePeripheral peripheral = new DigitalInterfacePeripheral(this);
|
|
||||||
|
|
||||||
// public TardimData getTardimDataInitial() {
|
|
||||||
// int X = this.getPos().getX(), Z = this.getPos().getZ();
|
|
||||||
//
|
|
||||||
// int index = 0;
|
|
||||||
// int x = 0;
|
|
||||||
// int y = 0;
|
|
||||||
// int dx = 0;
|
|
||||||
// int dy = 1;
|
|
||||||
// int segment_length = 1;
|
|
||||||
// int segment_passed = 0;
|
|
||||||
// boolean found = false;
|
|
||||||
// long timecheck = System.currentTimeMillis();
|
|
||||||
//
|
|
||||||
// while(true) {
|
|
||||||
// if (System.currentTimeMillis() - timecheck > 10000L) {
|
|
||||||
// System.out.println("Finding ID from XZ Coordinates is taking too long!");
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (X >= x * TardimManager.INTERIOR_BOUNDS
|
|
||||||
// && X <= TardimManager.INTERIOR_BOUNDS + x * TardimManager.INTERIOR_BOUNDS
|
|
||||||
// && Z >= y * TardimManager.INTERIOR_BOUNDS
|
|
||||||
// && Z <= TardimManager.INTERIOR_BOUNDS + y * TardimManager.INTERIOR_BOUNDS) {
|
|
||||||
// found = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// x += dx;
|
|
||||||
// y += dy;
|
|
||||||
// if (++segment_passed == segment_length) {
|
|
||||||
// segment_passed = 0;
|
|
||||||
// int buffer = dy;
|
|
||||||
// dy = -dx;
|
|
||||||
// dx = buffer;
|
|
||||||
// if (buffer == 0) {
|
|
||||||
// ++segment_length;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ++index;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // We really don't want to access a ghost TARDIM, do we?
|
|
||||||
// // If we fail checks here are not inside a TARDIM
|
|
||||||
// if (!found) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// TardimData T = TardimManager.getTardim(index);
|
|
||||||
// if (T.getCurrentLocation() == null || T.getOwnerName() == null) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return T;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void load(CompoundTag tag) {
|
|
||||||
// super.load(tag);
|
|
||||||
// this.data = getTardimDataInitial();
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package su.a71.tardim_ic.tardim_ic.digital_interface;
|
|
||||||
|
|
||||||
import com.swdteam.tardim.tardim.TardimData;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
|
|
||||||
public interface IDigitalInterfaceEntity {
|
|
||||||
public BlockPos getPos();
|
|
||||||
public Level getLevel();
|
|
||||||
|
|
||||||
public TardimData getTardim();
|
|
||||||
}
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package su.a71.tardim_ic.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;
|
||||||
|
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 furance fuel into it.
|
||||||
|
@Mixin(value = TardimManager.class, remap = false)
|
||||||
|
public class BetterFuelMapMixin {
|
||||||
|
|
||||||
|
@Overwrite
|
||||||
|
public static boolean isFuel(Item i) {
|
||||||
|
return FUEL_MAP.containsKey(i) || AbstractFurnaceBlockEntity.getFuel().containsKey(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Overwrite
|
||||||
|
public static double getFuel(Item i) {
|
||||||
|
if (!isFuel(i)) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!AbstractFurnaceBlockEntity.getFuel().containsKey(i)) {
|
||||||
|
return (Double)FUEL_MAP.get(i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return AbstractFurnaceBlockEntity.getFuel().get(i) / 8000.0; // Adapt with coal's 1600 ticks -> 0.2 fuel
|
||||||
|
}
|
||||||
|
|
||||||
|
// //@Inject(method = "getFuel(Lnet/minecraft/world/item/Item;)V", at = @At("TAIL"))
|
||||||
|
// @Overwrite
|
||||||
|
// public static void getFuel(Item i, CallbackInfo info) {
|
||||||
|
// LOG.info("We're in #TARDIM");
|
||||||
|
// if (AbstractFurnaceBlockEntity.getFuel().containsKey(i)) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package su.a71.tardim_ic.tardim_ic.mixin;
|
||||||
|
|
||||||
|
import com.swdteam.tardim.common.block.BlockFuelStorage;
|
||||||
|
import com.swdteam.tardim.common.init.TRDDimensions;
|
||||||
|
import com.swdteam.tardim.tardim.TardimData;
|
||||||
|
import com.swdteam.tardim.tardim.TardimManager;
|
||||||
|
import com.swdteam.tardim.tileentity.TileEntityFuelStorage;
|
||||||
|
import net.fabricmc.loader.impl.util.log.Log;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.item.BucketItem;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.level.block.HopperBlock;
|
||||||
|
import net.minecraft.world.level.block.entity.HopperBlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
|
import static su.a71.tardim_ic.tardim_ic.Constants.LOG;
|
||||||
|
|
||||||
|
@Mixin(value = TileEntityFuelStorage.class, remap = false)
|
||||||
|
public class BetterFuelStorageMixin {
|
||||||
|
|
||||||
|
// This is rather inefficient as we iterate 2 times
|
||||||
|
// However, the hoppers are so small and this method is called so rarely that it should be fine.
|
||||||
|
@Inject(method = "serverTick(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lcom/swdteam/tardim/tileentity/TileEntityFuelStorage;)V",
|
||||||
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/entity/HopperBlockEntity;removeItem(II)Lnet/minecraft/world/item/ItemStack;"),
|
||||||
|
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||||
|
private static void saveLavaBuckets(Level world, BlockPos pos, BlockState state, TileEntityFuelStorage blockEntity, CallbackInfo ci) {
|
||||||
|
//CAPTURE_FAILHARD: If the calculated locals are different from the expected values, throws an error.
|
||||||
|
HopperBlockEntity mixin_hopper = (HopperBlockEntity)world.getBlockEntity(blockEntity.getBlockPos().above());
|
||||||
|
for(int j = 0; j < mixin_hopper.getContainerSize(); ++j) {
|
||||||
|
ItemStack stack = mixin_hopper.getItem(j);
|
||||||
|
double fuel = TardimManager.getFuel(stack.getItem());
|
||||||
|
if (fuel > 0.0) {
|
||||||
|
if (stack.getItem() instanceof BucketItem) {
|
||||||
|
LOG.info("THIS IS A BUCKET");
|
||||||
|
mixin_hopper.setItem(j, new ItemStack(stack.getItem().getCraftingRemainingItem(), 2));
|
||||||
|
} else {
|
||||||
|
mixin_hopper.removeItem(j, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,14 +22,14 @@ import static su.a71.tardim_ic.tardim_ic.Registration.LOCATION_JAMMER;
|
||||||
|
|
||||||
@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", target = "Lcom/swdteam/tardim/tardim/TardimData;setTravelLocation(Lcom/swdteam/tardim/tardim/TardimData$Location;)V"))
|
// @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) {
|
// 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();
|
||||||
// };
|
//// };
|
||||||
// }
|
//// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,12 @@ import com.swdteam.tardim.common.init.CommandManager;
|
||||||
|
|
||||||
import su.a71.tardim_ic.tardim_ic.command.CommandCloisterBell;
|
import su.a71.tardim_ic.tardim_ic.command.CommandCloisterBell;
|
||||||
import su.a71.tardim_ic.tardim_ic.command.CommandListBiomes;
|
import su.a71.tardim_ic.tardim_ic.command.CommandListBiomes;
|
||||||
|
import su.a71.tardim_ic.tardim_ic.command.CommandListDimensions;
|
||||||
|
|
||||||
public class CommandInit {
|
public class CommandInit {
|
||||||
public static void init() {
|
public static void init() {
|
||||||
CommandManager.register(new CommandListBiomes());
|
CommandManager.register(new CommandListBiomes());
|
||||||
|
CommandManager.register(new CommandListDimensions());
|
||||||
CommandManager.register(new CommandCloisterBell());
|
CommandManager.register(new CommandCloisterBell());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,9 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import su.a71.tardim_ic.tardim_ic.Constants;
|
import su.a71.tardim_ic.tardim_ic.Constants;
|
||||||
import su.a71.tardim_ic.tardim_ic.Registration;
|
import su.a71.tardim_ic.tardim_ic.Registration;
|
||||||
import su.a71.tardim_ic.tardim_ic.command.CommandModemTransmit;
|
import su.a71.tardim_ic.tardim_ic.command.CommandModemTransmit;
|
||||||
import su.a71.tardim_ic.tardim_ic.digital_interface.DigitalInterfaceBlock;
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.TardimPeripheralProvider;
|
||||||
import su.a71.tardim_ic.tardim_ic.digital_interface.DigitalInterfacePeripheralProvider;
|
import su.a71.tardim_ic.tardim_ic.computercraft_compat.blocks.digital_interface.DigitalInterfaceBlock;
|
||||||
import su.a71.tardim_ic.tardim_ic.digital_interface.DigitalInterfaceTileEntity;
|
import su.a71.tardim_ic.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();
|
||||||
|
@ -31,6 +31,6 @@ public class ComputerCraftCompat {
|
||||||
Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "digital_tardim_interface"), new BlockItem(DIGITAL_TARDIM_INTERFACE, new FabricItemSettings().tab(Registration.TARDIM_IC_TAB)));
|
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());
|
CommandManager.register(new CommandModemTransmit());
|
||||||
ComputerCraftAPI.registerPeripheralProvider(new DigitalInterfacePeripheralProvider());
|
ComputerCraftAPI.registerPeripheralProvider(new TardimPeripheralProvider());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"refmap": "refmap.tardim_ic.json",
|
"refmap": "refmap.tardim_ic.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"BetterFuelMapMixin",
|
||||||
|
"BetterFuelStorageMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
],
|
],
|
||||||
|
|
|
@ -6,4 +6,10 @@
|
||||||
5. com.swdteam.tardim.common.data.DimensionMapReloadListener has modid tutorial in
|
5. com.swdteam.tardim.common.data.DimensionMapReloadListener has modid tutorial in
|
||||||
public ResourceLocation getFabricId() {
|
public ResourceLocation getFabricId() {
|
||||||
return new ResourceLocation("tutorial", "tardim_dimension_lookup");
|
return new ResourceLocation("tutorial", "tardim_dimension_lookup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Andrew71's proposals:
|
||||||
|
|
||||||
|
1. Quick-return command
|
||||||
|
2. add support for far more fuel sources via AbstractFurnaceBlockEntity.getFuel() on top of built-in TARDIM method
|
||||||
|
3. Unify package names on Forge and Fabric
|
8
TODO.txt
8
TODO.txt
|
@ -11,7 +11,7 @@ Items:
|
||||||
Commands:
|
Commands:
|
||||||
Quick return - set destination to previous materialisation point.
|
Quick return - set destination to previous materialisation point.
|
||||||
Compat:
|
Compat:
|
||||||
CC - add more meaningful peripherals to things like fuel tank
|
CC - add more meaningful peripherals to things like fuel tank, CREATIVE INTERFACE?
|
||||||
Create - Port to 0.5.1, add display sources to more things. Also look into mechanical TARDIM power-up
|
Create - Port to 0.5.1, add display sources to more things. Also look into mechanical TARDIM power-up
|
||||||
|
|
||||||
Mixins:
|
Mixins:
|
||||||
|
@ -44,4 +44,8 @@ Achievements/Advancements:
|
||||||
Put on a location jammer
|
Put on a location jammer
|
||||||
|
|
||||||
"I will always remember..."
|
"I will always remember..."
|
||||||
Save (or maybe lock like a map?) a location cartridge
|
Save (or maybe lock like a map?) a location cartridge
|
||||||
|
|
||||||
|
Crafting recipe for floppy with tardim tutorial installer
|
||||||
|
|
||||||
|
Power indicator for redstone interface
|
Loading…
Add table
Reference in a new issue