Compare commits

..

No commits in common. "1.20" and "multiloader-1.19" have entirely different histories.

207 changed files with 2714 additions and 2470 deletions

1
.gitignore vendored
View file

@ -21,4 +21,3 @@ build
# other
eclipse
run
/.idea/

15
CHANGELOG.txt Normal file
View 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

69
Common/build.gradle Normal file
View file

@ -0,0 +1,69 @@
plugins {
id 'java'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
id 'maven-publish'
}
archivesBaseName = "${mod_name}-common-${minecraft_version}"
minecraft {
version(minecraft_version)
runs {
if (project.hasProperty('common_runs_enabled') ? project.findProperty('common_runs_enabled').toBoolean() : true) {
server(project.hasProperty('common_server_run_name') ? project.findProperty('common_server_run_name') : 'vanilla_server') {
workingDirectory(this.file("run"))
}
client(project.hasProperty('common_client_run_name') ? project.findProperty('common_client_run_name') : 'vanilla_client') {
workingDirectory(this.file("run"))
}
}
}
}
repositories {
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}
dependencies {
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
// CC: R and TARDIM
//implementation("curse.maven:cc-restitched-462672:3908334")
//compileOnly("org.squiddev:cc-tweaked-1.19.1:${cc_version}")
//compileOnly("curse.maven:tardim-531315:4453925")
//implementation ("org.squiddev:cc-tweaked-1.19.1:${cc_version}")
}
processResources {
def buildProps = project.properties.clone()
filesMatching(['pack.mcmeta']) {
expand buildProps
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic;
package su.a71.tardim_ic.tardim_ic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.utils;
package su.a71.tardim_ic.tardim_ic.utils;
import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPos;
@ -7,18 +7,14 @@ import net.minecraft.world.level.Level;
import java.util.UUID;
/**
* This class is used whenever we need a player for a function but cannot get one
* (i.g we are on server side and need to execute TARDIM command)
*/
public class FakePlayer extends Player {
public FakePlayer(Level lvl, BlockPos blockPos) {
super(lvl, blockPos, 0, new GameProfile(UUID.randomUUID(), "FakePlayer_tardimic"));
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"));
super(lvl, blockPos, 0, new GameProfile(id, "FakePlayer_tardimic"), null);
}
@ -32,3 +28,5 @@ public class FakePlayer extends Player {
return false;
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "tardim_ic:block/tardim_dock"
}
}
}

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
{
"credit": "Made with Blockbench",
"credit": "Made by karoter2 with Blockbench",
"parent": "digital_tardim_interface",
"texture_size": [64, 64],
"textures": {

View file

@ -2,8 +2,8 @@
"credit": "Made by karoter2 (Feulim)",
"texture_size": [128, 128],
"textures": {
"0": "tardim_ic:block/food_machine",
"particle": "tardim_ic:block/food_machine"
"0": "tardim_ic:blocks/food_machine",
"particle": "tardim_ic:blocks/food_machine"
},
"elements": [
{

View file

@ -1,5 +1,5 @@
{
"credit": "Made with Blockbench",
"credit": "Made by karoter2 with Blockbench",
"parent": "block/cube_all",
"ambientocclusion": false,
"textures": {

View file

@ -1,9 +1,9 @@
{
"credit": "Made by karoter2 (Feulim)",
"credit": "Made by karoter2 with Blockbench",
"texture_size": [64, 64],
"textures": {
"1": "tardim_ic:block/tardim_dock",
"particle": "tardim_ic:block/tardim_dock"
"1": "tardim_ic:blocks/tardim_dock",
"particle": "tardim_ic:blocks/tardim_dock"
},
"elements": [
{

View file

@ -1,6 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "tardim_ic:item/personal_jammer"
"layer0": "tardim_ic:item/location_jammer"
}
}

View file

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

View file

@ -0,0 +1,6 @@
{
"pack": {
"description": "TARDIM: In Control resources",
"pack_format": 6
}
}

79
Fabric/build.gradle Normal file
View file

@ -0,0 +1,79 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
id 'idea'
}
archivesBaseName = "${mod_name}-fabric-${minecraft_version}"
dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
implementation project(":Common")
// Blame CC: Restitched for this...
modApi 'com.electronwill.night-config:core:3.6.3'
modApi 'com.electronwill.night-config:toml:3.6.3'
modApi 'org.squiddev:Cobalt:0.5.5'
modImplementation "io.netty:netty-codec-http:4.1.77.Final"
modImplementation "curse.maven:tardim-531315:4453924"
//modImplementation "curse.maven:cc-restitched-462672:3908334"
//.. maybe?
modApi "curse.maven:cc-restitched-462672:3908334"
modCompileOnly "curse.maven:cc-restitched-462672:3908334"
// Create!
modCompileOnly "curse.maven:create-fabric-624165:4537370"
}
loom {
runs {
client {
client()
setConfigName("Fabric Client")
ideConfigGenerated(true)
runDir("run")
}
server {
server()
setConfigName("Fabric Server")
ideConfigGenerated(true)
runDir("run")
}
}
}
processResources {
from project(":Common").sourceSets.main.resources
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile) {
source(project(":Common").sourceSets.main.allSource)
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}

View file

@ -0,0 +1,79 @@
package su.a71.tardim_ic.tardim_ic;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.*;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.core.Registry;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
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.blocks.redstone_input.RedstoneInputBlock;
import su.a71.tardim_ic.tardim_ic.blocks.redstone_input.RedstoneInputTileEntity;
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.CreateCompat;
import su.a71.tardim_ic.tardim_ic.registration.Exteriors;
public class Registration {
// Blocks
public static final Block REDSTONE_TARDIM_INPUT = new RedstoneInputBlock();
public static final Block FOOD_MACHINE = new FoodMachineBlock();
// Tile Entities
public static final BlockEntityType<RedstoneInputTileEntity> REDSTONE_TARDIM_INPUT_TILEENTITY = Registry.register(
Registry.BLOCK_ENTITY_TYPE,
new ResourceLocation("tardim_ic", "redstone_tardim_input"),
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
.create(new ResourceLocation("tardim_ic"))
.icon(() -> new ItemStack(REDSTONE_TARDIM_INPUT))
.build();
// Cloister bell
public static final ResourceLocation CLOISTER_SOUND = new ResourceLocation("tardim_ic:cloister");
public static SoundEvent CLOISTER_SOUND_EVENT = new SoundEvent(CLOISTER_SOUND);
public static final ArmorMaterial LOCATION_JAMMER_MATERIAL = new LocationJammerMaterial();
public static final Item LOCATION_JAMMER = new ArmorItem(LOCATION_JAMMER_MATERIAL, EquipmentSlot.CHEST, new Item.Properties().tab(TARDIM_IC_TAB));
// Register our stuff
public static void register() {
Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "location_jammer"), LOCATION_JAMMER);
if (FabricLoader.getInstance().isModLoaded("computercraft")) {
ComputerCraftCompat.register(); // Register ComputerCraft-related features
}
if (FabricLoader.getInstance().isModLoaded("create")) {
CreateCompat.register(); // Register Create-related features
}
Exteriors.register(); // Register custom TARDIM exteriors
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.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);
CommandInit.init();
}
}

View file

@ -1,10 +1,9 @@
package su.a71.tardim_ic;
package su.a71.tardim_ic.tardim_ic;
import net.fabricmc.api.ModInitializer;
import su.a71.tardim_ic.tardim_ic.registration.Registration;
public class TardimInControl implements ModInitializer {
@Override
public void onInitialize() {
Registration.register();

View file

@ -1,13 +1,19 @@
package su.a71.tardim_ic.blocks.food_machine;
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;
@ -23,21 +29,27 @@ 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.MapColor;
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.Registration;
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(Properties.of().strength(2, 4).noOcclusion().mapColor(MapColor.METAL)); // No occlusion?
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) {
@ -51,7 +63,7 @@ public class FoodMachineBlock extends HorizontalDirectionalBlock implements Enti
@Nullable
@Override
public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
return Registration.FOOD_MACHINE_BE.create(pos, state);
return Registration.FOOD_MACHINE_TILEENTITY.create(pos, state);
}
@Override
@ -59,16 +71,17 @@ public class FoodMachineBlock extends HorizontalDirectionalBlock implements Enti
if (!w.isClientSide) {
w.playSound(null, blockPos, TRDSounds.TARDIM_BEEP, SoundSource.BLOCKS, 0.3F, 0.5F);
BlockEntity be = w.getBlockEntity(blockPos);
if (be instanceof FoodMachineBlockEntity && w.dimension() == TRDDimensions.TARDIS) {
if (be instanceof FoodMachineTileEntity && w.dimension() == TRDDimensions.TARDIS) {
TardimData data = TardimManager.getFromPos(blockPos);
if (data != null && data.hasPermission(player)) {
if (data.getFuel() >= 0.2) {
data.setFuel(data.getFuel() - 0.2); // Remove some fuel in exchange for food
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 {

View file

@ -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");
}
}

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.blocks.redstone_input;
package su.a71.tardim_ic.tardim_ic.blocks.redstone_input;
import com.swdteam.tardim.common.block.BlockBaseTardimPanel;
import com.swdteam.tardim.common.init.TRDDimensions;
@ -26,25 +26,24 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull;
import su.a71.tardim_ic.tardim_ic.registration.Registration;
import su.a71.tardim_ic.utils.FakePlayer;
import su.a71.tardim_ic.tardim_ic.Registration;
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
import javax.annotation.Nullable;
public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBlock {
public RedstoneInputBlock() {
super(FabricBlockSettings.create().strength(2, 4).mapColor(MapColor.TERRACOTTA_ORANGE)); // No occlusion? this.setDefaultState((BlockState)this.getDefaultState().with(ON, false));
super(FabricBlockSettings.of(Material.METAL).strength(2, 4)); // No occlusion?
}
@Nullable
@Override
public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
return Registration.REDSTONE_INPUT_BE.create(pos, state);
return Registration.REDSTONE_TARDIM_INPUT_TILEENTITY.create(pos, state);
}
@Override
@ -54,10 +53,10 @@ public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBl
w.playSound(null, blockPos, TRDSounds.TARDIM_BEEP, SoundSource.BLOCKS, 0.3F, 0.5F);
BlockEntity be = w.getBlockEntity(blockPos);
if (be instanceof RedstoneInputBlockEntity && w.dimension() == TRDDimensions.TARDIS) {
if (be instanceof RedstoneInputTileEntity && w.dimension() == TRDDimensions.TARDIS) {
TardimData data = TardimManager.getFromPos(blockPos);
if (data != null && data.hasPermission(player)) {
((RedstoneInputBlockEntity) be).lastPlayer = player.getGameProfile().getId();
((RedstoneInputTileEntity) be).lastPlayer = player.getGameProfile().getId();
NetworkHandler.sendTo((ServerPlayer)player, new PacketOpenEditGui(blockPos, 1));
return InteractionResult.CONSUME;
}
@ -79,26 +78,25 @@ public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBl
DebugPackets.sendNeighborsUpdatePacket(level, blockPos);
BlockEntity be = level.getBlockEntity(blockPos);
if (!(be instanceof RedstoneInputBlockEntity)) {
if (!(be instanceof RedstoneInputTileEntity)) {
return;
}
// get redstone signal
Direction direction = blockState.getValue(FACING);
int redstoneSignal = level.getSignal(blockPos, direction);
if (redstoneSignal > 0 && !((RedstoneInputBlockEntity) be).isPowered) {
((RedstoneInputBlockEntity) be).isPowered = true;
if (redstoneSignal > 0 && !((RedstoneInputTileEntity) be).isPowered) {
((RedstoneInputTileEntity) be).isPowered = true;
if (level.dimension() == TRDDimensions.TARDIS) {
TardimData data = TardimManager.getFromPos(blockPos);
if (data != null && !level.isClientSide && ((RedstoneInputBlockEntity) be).lastPlayer != null) {
if (data != null && !level.isClientSide && ((RedstoneInputTileEntity) be).lastPlayer != null) {
if (((TileEntityBaseTardimPanel)be).hasCommand()) {
((TileEntityBaseTardimPanel)be).execute(new FakePlayer(level, blockPos, ((RedstoneInputBlockEntity) be).lastPlayer));
((TileEntityBaseTardimPanel)be).execute(new FakePlayer(level, blockPos, ((RedstoneInputTileEntity) be).lastPlayer));
}
}
}
} else if (redstoneSignal == 0 && ((RedstoneInputBlockEntity) be).isPowered) {
((RedstoneInputBlockEntity) be).isPowered = false;
}
} else if (redstoneSignal == 0 && ((RedstoneInputTileEntity) be).isPowered)
((RedstoneInputTileEntity) be).isPowered = false;
}
}

View file

@ -1,21 +1,21 @@
package su.a71.tardim_ic.blocks.redstone_input;
package su.a71.tardim_ic.tardim_ic.blocks.redstone_input;
import com.swdteam.tardim.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.Registration;
import su.a71.tardim_ic.tardim_ic.Registration;
import java.util.UUID;
public class RedstoneInputBlockEntity extends TileEntityBaseTardimPanel {
public class RedstoneInputTileEntity extends TileEntityBaseTardimPanel {
public boolean isPowered = false;
public UUID lastPlayer = null;
public RedstoneInputBlockEntity(BlockPos pos, BlockState state) {
super(Registration.REDSTONE_INPUT_BE, pos, state);
public RedstoneInputTileEntity(BlockPos pos, BlockState state) {
super(Registration.REDSTONE_TARDIM_INPUT_TILEENTITY, pos, state);
}
public BlockPos getPos() {

View file

@ -0,0 +1,4 @@
"Base:"
* Quartz
* Deepslate
* Stone?

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.command;
package su.a71.tardim_ic.tardim_ic.command;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.common.command.tardim.ICommand;
@ -9,8 +9,8 @@ import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import su.a71.tardim_ic.tardim_ic.registration.Registration;
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.
@ -23,12 +23,12 @@ public class CommandCloisterBell implements ICommand {
if (data != null) {
if (data.hasPermission(player)) {
try {
Level lvl = player.level();
Level lvl = player.getLevel();
if (!lvl.isClientSide) {
lvl.playSound(
null,
pos,
Registration.CLOISTER_BELL,
Registration.CLOISTER_SOUND_EVENT,
SoundSource.BLOCKS,
1.5f,
1f

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.command;
package su.a71.tardim_ic.tardim_ic.command;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.common.command.tardim.ICommand;
@ -6,7 +6,6 @@ import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.FurnaceFuelSlot;
@ -27,7 +26,7 @@ public class CommandListBiomes implements ICommand{
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
Registry<Biome> biomeRegistry = player.level().registryAccess().registryOrThrow(Registries.BIOME);
Registry<Biome> biomeRegistry = player.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
biomeRegistry.keySet().forEach(
(ResourceLocation res) -> {
String out = res.toString();

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.command;
package su.a71.tardim_ic.tardim_ic.command;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.common.command.tardim.ICommand;
@ -18,7 +18,7 @@ public class CommandListDimensions implements ICommand{
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
for (ServerLevel serverLevel : player.level().getServer().getAllLevels()) {
for (ServerLevel serverLevel : player.getLevel().getServer().getAllLevels()) {
CommandTardimBase.sendResponse(player, serverLevel.dimension().location().toString(), CommandTardimBase.ResponseType.INFO, source);
}
} else {

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.command;
package su.a71.tardim_ic.tardim_ic.command;
// This will be added whenever I manage to convince TARDIM devs to make CommandManager.register public
// 13.04.23 ITS ALIVE
@ -38,10 +38,10 @@ public class CommandModemTransmit implements ICommand {
if (allDimensions)
{
ComputerCraftAPI.getWirelessNetwork(player.getServer()).transmitInterdimensional(new Packet(sendChannel, replyChannel, message, new CommandSender(player, data.getTravelLocation().getPos())));
ComputerCraftAPI.getWirelessNetwork().transmitInterdimensional(new Packet(sendChannel, replyChannel, message, new CommandSender(player, data.getTravelLocation().getPos())));
}
else {
ComputerCraftAPI.getWirelessNetwork(player.getServer()).transmitSameDimension(new Packet(sendChannel, replyChannel, message,
ComputerCraftAPI.getWirelessNetwork().transmitSameDimension(new Packet(sendChannel, replyChannel, message,
new CommandSender(player, data.getTravelLocation().getPos())), 300);
}
CommandTardimBase.sendResponse(player, "Sent modem message", CommandTardimBase.ResponseType.COMPLETE, source);

View file

@ -1,13 +1,13 @@
package su.a71.tardim_ic.command;
package su.a71.tardim_ic.tardim_ic.command;
import dan200.computercraft.api.network.PacketSender;
import dan200.computercraft.api.network.IPacketSender;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
public class CommandSender implements PacketSender {
public class CommandSender implements IPacketSender {
private final Player player;
private final Level level;
@ -15,7 +15,7 @@ public class CommandSender implements PacketSender {
CommandSender(Player player, BlockPos pos) {
this.player = player;
this.level = player.level();
this.level = player.level;
this.pos = pos;
}

View file

@ -1,16 +1,16 @@
package su.a71.tardim_ic.computercraft_compat.entity;
package su.a71.tardim_ic.tardim_ic.computercraft_compat;
import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
public class FakeTardimPeripheralTileEntity implements ITardimPeripheralTileEntity {
public BlockPos blockPos;
public Level level;
public TardimData data; // Our TARDIM
public FakeTardimPeripheralTileEntity(BlockPos in_block, Level in_level) {
this.blockPos = in_block;
this.level = in_level;
@ -32,11 +32,6 @@ public class FakeTardimPeripheralTileEntity implements ITardimPeripheralTileEnti
return this.data;
}
@Override
public Block getBlock() {
return this.level.getBlockState(this.blockPos).getBlock();
}
public TardimData getTardimDataInitial() {
int X = this.getPos().getX(), Z = this.getPos().getZ();

View file

@ -1,18 +1,14 @@
package su.a71.tardim_ic.computercraft_compat.entity;
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;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
// 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.
// 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();
public Block getBlock();
}

View file

@ -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;
}
}

View file

@ -1,12 +1,13 @@
package su.a71.tardim_ic.computercraft_compat.digital_interface;
package su.a71.tardim_ic.tardim_ic.computercraft_compat.blocks.digital_interface;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.material.Material;
import org.jetbrains.annotations.NotNull;
import su.a71.tardim_ic.tardim_ic.Registration;
import su.a71.tardim_ic.tardim_ic.registration.ComputerCraftCompat;
import javax.annotation.Nullable;
@ -15,12 +16,12 @@ import javax.annotation.Nullable;
public class DigitalInterfaceBlock extends Block implements EntityBlock {
public DigitalInterfaceBlock() {
super(Properties.of().strength(2, 4).noOcclusion().mapColor(MapColor.METAL));
super(Properties.of(Material.METAL).strength(2, 4).noOcclusion());
}
@Nullable
@Override
public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
return ComputerCraftCompat.DIGITAL_INTERFACE_BE.create(pos, state);
return ComputerCraftCompat.DIGITAL_TARDIM_INTERFACE_TILEENTITY.create(pos, state);
}
}

View file

@ -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);
}
}

View file

@ -1,9 +1,11 @@
package su.a71.tardim_ic.computercraft_compat.peripherals;
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
import com.swdteam.tardim.common.command.tardim.CommandTravel;
import com.swdteam.tardim.common.data.DimensionMapReloadListener;
import com.swdteam.tardim.common.init.TRDSounds;
import com.swdteam.tardim.common.init.TardimRegistry;
import com.swdteam.tardim.common.item.ItemTardim;
import com.swdteam.tardim.main.Tardim;
import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimData.Location;
import com.swdteam.tardim.tardim.TardimManager;
@ -18,7 +20,6 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
@ -30,28 +31,34 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.phys.Vec3;
import su.a71.tardim_ic.computercraft_compat.digital_interface.DigitalInterfaceBlock;
import su.a71.tardim_ic.computercraft_compat.entity.FakeTardimPeripheralTileEntity;
import su.a71.tardim_ic.tardim_ic.registration.Registration;
import su.a71.tardim_ic.utils.FakePlayer;
import 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 static su.a71.tardim_ic.tardim_ic.Registration.LOCATION_JAMMER;
import javax.annotation.Nonnull;
import java.util.*;
public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfaceBlock> implements IPeripheral {
public class DigitalInterfacePeripheral extends TardimPeripheral implements IPeripheral {
/**
* @param tileEntity the tile entity of this peripheral
* @hidden
*/
public DigitalInterfacePeripheral(FakeTardimPeripheralTileEntity tileEntity) {
super(tileEntity, "digital_tardim_interface", (DigitalInterfaceBlock) tileEntity.getBlock());
super(tileEntity);
}
/** Setting name for the peripheral. A computer will see it as "digital_tardim_interface_n"
* @hidden
*/
@Nonnull
@Override
public String getType() { return "digital_tardim_interface"; }
// Peripheral methods ===============================================================
/**
@ -151,7 +158,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/
@LuaFunction(mainThread = true)
public final ObjectLuaTable getCurrentLocation() throws LuaException {
Location loc = getTardimData().getCurrentLocation();
Location loc = getTardimData().getCurrentLocation();
return new ObjectLuaTable(Map.of(
"dimension", loc.getLevel().location().toString(),
"pos", new ObjectLuaTable(Map.of(
@ -176,7 +183,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/
@LuaFunction(mainThread = true)
public final ObjectLuaTable getTravelLocation() throws LuaException {
TardimData data = getTardimData();
TardimData data = getTardimData();
if (data.getTravelLocation() == null) {
data.setTravelLocation(data.getCurrentLocation());
}
@ -198,12 +205,12 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/
@LuaFunction(mainThread = true)
public final ObjectLuaTable getCompanions() throws LuaException {
TardimData data = getTardimData();
TardimData data = getTardimData();
Map<Integer, String> companions = new HashMap<>();
for (int i = 0; i < data.getCompanions().size(); i++) {
companions.put(i + 1, data.getCompanions().get(i).getUsername());
}
return new ObjectLuaTable(companions);
for (int i = 0; i < data.getCompanions().size(); i++) {
companions.put(i + 1, data.getCompanions().get(i).getUsername());
}
return new ObjectLuaTable(companions);
}
/**
@ -211,7 +218,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
* SWDteam pls fix
* @hidden
*/
private boolean isValidPathTemp(String s) {
private static boolean isValidPathTemp(String s) {
for(int i = 0; i < s.length(); ++i) {
if (!CommandTravel.validPathChar(s.charAt(i))) {
return false;
@ -220,32 +227,6 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
return true;
}
/**
* DimensionMapReloadListener.toTitleCase is unavailable so we reverse engineer it! :D
* Fabric... pls fix?
* @hidden
*/
private String toTitleCase(String input) {
StringBuilder titleCase = new StringBuilder(input.length());
boolean nextTitleCase = true;
char[] var3 = input.toCharArray();
int var4 = var3.length;
for(int var5 = 0; var5 < var4; ++var5) {
char c = var3[var5];
if (Character.isSpaceChar(c)) {
nextTitleCase = true;
} else if (nextTitleCase) {
c = Character.toTitleCase(c);
nextTitleCase = false;
}
titleCase.append(c);
}
return titleCase.toString();
}
/**
* Set dimension for the TARDIM to travel to
* <p>
@ -256,10 +237,10 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/
@LuaFunction(mainThread = true)
public final void setDimension(String dimension) throws LuaException {
TardimData data = getTardimData();
TardimData data = getTardimData();
String key = dimension;
dimension = toTitleCase(dimension);
dimension = DimensionMapReloadListener.toTitleCase(dimension);
if (TardimManager.DIMENSION_MAP.containsKey(dimension)) {
key = (String)TardimManager.DIMENSION_MAP.get(dimension);
} else {
@ -269,7 +250,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
if (!isValidPathTemp(key)) {
throw new LuaException("Invalid dimension");
} else {
ResourceKey<Level> dim = ResourceKey.create(Registries.DIMENSION, new ResourceLocation(dimension));
ResourceKey<Level> dim = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(dimension));
if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation()));
}
@ -303,7 +284,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
if (this.getTileEntity().getLevel().isClientSide()) {
return;
}
TardimData data = getTardimData();
TardimData data = getTardimData();
UUID uuid = data.getOwner();
String username = data.getOwnerName();
@ -340,22 +321,21 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
PlayerList playerList = this.getTileEntity().getLevel().getServer().getPlayerList();
ServerPlayer player = playerList.getPlayerByName(username);
if (player == null) {
throw new LuaException("Player not found");
if (player == null) {
throw new LuaException("Player not found");
}
for (ItemStack armour : player.getArmorSlots()) {
if (armour.is(LOCATION_JAMMER)) {
throw new LuaException("Player location jammed");
};
}
// for (ItemStack armour : player.getArmorSlots()) {
//// if (armour.is(PERSONAL_JAMMER)) {
//// throw new LuaException("Player location jammed");
//// };
// // TODO: Re-add
// }
ResourceKey<Level> dim = player.getCommandSenderWorld().dimension();
BlockPos pos = player.blockPosition();
ResourceKey<Level> dim = player.getCommandSenderWorld().dimension();
BlockPos pos = player.blockPosition();
setDimension(dim.location().toString());
setTravelLocation(pos.getX(), pos.getY(), pos.getZ());
setDimension(dim.location().toString());
setTravelLocation(pos.getX(), pos.getY(), pos.getZ());
}
/**
@ -369,13 +349,13 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
return null;
}
PlayerList playerList = this.getTileEntity().getLevel().getServer().getPlayerList();
PlayerList playerList = this.getTileEntity().getLevel().getServer().getPlayerList();
Map<Integer, String> players = new HashMap<>();
for (int i = 0; i < playerList.getPlayers().size(); i++) {
players.put(i + 1, playerList.getPlayers().get(i).getGameProfile().getName());
}
return new ObjectLuaTable(players);
return new ObjectLuaTable(players);
}
/**
@ -384,8 +364,8 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/
@LuaFunction(mainThread = true)
public final String getDoorRotation() throws LuaException {
TardimData data = getTardimData();
Direction rotation = data.getTravelLocation().getFacing();
TardimData data = getTardimData();
Direction rotation = data.getTravelLocation().getFacing();
switch (rotation) {
case NORTH -> {
return "north";
@ -411,7 +391,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/
@LuaFunction(mainThread = true)
public final void setDoorRotation(String rotation) throws LuaException {
TardimData data = getTardimData();
TardimData data = getTardimData();
switch (rotation) {
case "north" -> data.getTravelLocation().setFacing(Direction.NORTH);
case "east" -> data.getTravelLocation().setFacing(Direction.EAST);
@ -428,7 +408,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/
@LuaFunction(mainThread = true)
public final void toggleDoorRotation() throws LuaException {
TardimData data = getTardimData();
TardimData data = getTardimData();
if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation()));
}
@ -455,18 +435,18 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
*/
@LuaFunction(mainThread = true)
public final void coordAdd(String axis, int amount) throws LuaException {
TardimData data = getTardimData();
if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation()));
}
TardimData data = getTardimData();
if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation()));
}
Location location = data.getTravelLocation();
switch (axis) {
case "x" -> location.addPosition(amount, 0, 0);
Location location = data.getTravelLocation();
switch (axis) {
case "x" -> location.addPosition(amount, 0, 0);
case "y" -> location.addPosition(0, amount, 0);
case "z" -> location.addPosition(0, 0, amount);
default -> throw new LuaException("Invalid axis");
}
}
}
/**
@ -478,7 +458,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
return;
}
TardimData data = getTardimData();
TardimData data = getTardimData();
if (data.isInFlight()) {
throw new LuaException("TARDIM is already in flight");
@ -487,35 +467,17 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(loc.getLevel());
ItemTardim.destroyTardim(level, loc.getPos(), Direction.NORTH);
data.setInFlight(true);
if (data.getTravelLocation() == null) {
if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation()));
}
// TODO: This is a horrendous way of doing this. Please fix.
String level_str = "tardim:tardis_dimension";
this.tileEntity.getLevel().getServer().getLevel(ResourceKey.create(Registries.DIMENSION, new ResourceLocation(level_str))).playSound(null, this.tileEntity.getPos(), (SoundEvent) TRDSounds.TARDIM_TAKEOFF, SoundSource.AMBIENT, 1.0F, 1.0F);
this.tileEntity.getLevel().getServer().getLevel(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(level_str))).playSound(null, this.tileEntity.getPos(), (SoundEvent) TRDSounds.TARDIM_TAKEOFF, SoundSource.AMBIENT, 1.0F, 1.0F);
data.save();
}
/**
* Way to use function from Tardim (ModInitializer)
* 1WTC pls fix
* @hidden
*/
public static boolean isPosValid(Level level, BlockPos pos) {
return validPos(level, pos) && validPos(level, pos.above()) && validPos(level, pos.above().above()) && validPos(level, pos.north()) && validPos(level, pos.north().above()) && validPos(level, pos.south()) && validPos(level, pos.south().above()) && validPos(level, pos.east()) && validPos(level, pos.east().above()) && validPos(level, pos.west()) && validPos(level, pos.west().above());
}
/**
* @see DigitalInterfacePeripheral#isPosValid(Level, BlockPos)
* @hidden
*/
private static boolean validPos(Level l, BlockPos pos) {
BlockState blockstate = l.getBlockState(pos);
return !blockstate.canBeReplaced() && blockstate.getBlock() != Blocks.SNOW ? blockstate.isAir() : true;
}
/**
* Materialize the TARDIM at the destination
* <p>
@ -592,7 +554,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
if (Block.canSupportRigidBlock(level, landingPosButBetter.below())) {
loc.setPosition(landingPosButBetter.getX(), landingPosButBetter.getY(), landingPosButBetter.getZ());
if (isPosValid(level, loc.getPos())) {
if (Tardim.isPosValid(level, loc.getPos())) {
TardimRegistry.TardimBuilder builder = TardimRegistry.getTardimBuilder(data.getTardimID());
builder.buildTardim(level, loc.getPos(), data.getTravelLocation().getFacing(), data.getId());
data.setCurrentLocation(data.getTravelLocation());
@ -609,7 +571,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
// }
String level_str = "tardim:tardis_dimension";
this.tileEntity.getLevel().getServer().getLevel(ResourceKey.create(Registries.DIMENSION, new ResourceLocation(level_str))).playSound(null, this.tileEntity.getPos(), (SoundEvent) TRDSounds.TARDIM_LANDING, SoundSource.AMBIENT, 1.0F, 1.0F);
this.tileEntity.getLevel().getServer().getLevel(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(level_str))).playSound(null, this.tileEntity.getPos(), (SoundEvent) TRDSounds.TARDIM_LANDING, SoundSource.AMBIENT, 1.0F, 1.0F);
} else {
throw new LuaException("TARDIM landing obstructed. Aborting...");
@ -645,7 +607,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
Optional<Biome> biome = this.tileEntity.getLevel().getServer()
.registryAccess()
.registryOrThrow(Registries.BIOME)
.registryOrThrow(Registry.BIOME_REGISTRY)
.getOptional(new ResourceLocation(biome_str));
if (biome != null && biome.isPresent()) {
if (data.getTravelLocation() == null) {
@ -780,7 +742,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
lvl.playSound(
null,
this.tileEntity.getPos(),
Registration.CLOISTER_BELL,
Registration.CLOISTER_SOUND_EVENT,
SoundSource.BLOCKS,
1.5f,
1f
@ -799,7 +761,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral<DigitalInterfac
@LuaFunction(mainThread = true)
public final ObjectLuaTable getBiomes() throws LuaException {
Map<Integer, String> biomes = new HashMap<>();
Registry<Biome> biomeRegistry = tileEntity.getLevel().registryAccess().registryOrThrow(Registries.BIOME);
Registry<Biome> biomeRegistry = tileEntity.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
Iterator<ResourceLocation> biome_it = biomeRegistry.keySet().iterator();
int i = 0;
while (biome_it.hasNext()) {

View file

@ -1,27 +1,35 @@
package su.a71.tardim_ic.computercraft_compat.peripherals;
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
import com.swdteam.tardim.common.block.BlockFuelStorage;
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.computercraft_compat.entity.FakeTardimPeripheralTileEntity;
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<BlockFuelStorage> implements IPeripheral {
public class FuelStoragePeripheral extends TardimPeripheral implements IPeripheral {
/**
* @param tileEntity the tile entity of this peripheral
* @hidden
*/
public FuelStoragePeripheral(FakeTardimPeripheralTileEntity tileEntity) {
super(tileEntity, "tardim_fuel_storage", (BlockFuelStorage) tileEntity.getBlock());
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 ===============================================================

View file

@ -1,47 +1,28 @@
package su.a71.tardim_ic.computercraft_compat.peripherals;
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 net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import su.a71.tardim_ic.computercraft_compat.entity.ITardimPeripheralTileEntity;
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<BL extends Block> implements IPeripheral {
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
public final String name;
private final BL block;
/**
* @param tileEntity the tile entity of this peripheral
* @hidden
*/
public TardimPeripheral(ITardimPeripheralTileEntity tileEntity, String name, BL block) {
public TardimPeripheral(ITardimPeripheralTileEntity tileEntity) {
this.tileEntity = tileEntity;
this.name = name;
this.block = block;
}
@Override
public BL getTarget() {
return this.block;
}
/** Setting name for the peripheral. A computer will see it as "digital_tardim_interface_n"
* @hidden
*/
@Nonnull
@Override
public String getType() { return this.name; }
/** 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}.

View file

@ -1,6 +1,5 @@
package su.a71.tardim_ic.computercraft_compat.peripherals;
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
import com.swdteam.tardim.common.block.BlockTardimScanner;
import com.swdteam.tardim.common.init.TardimRegistry;
import com.swdteam.tardim.tardim.TardimData;
import dan200.computercraft.api.lua.LuaException;
@ -8,13 +7,13 @@ 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.core.registries.Registries;
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.computercraft_compat.entity.FakeTardimPeripheralTileEntity;
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;
@ -25,15 +24,22 @@ import java.util.Map;
* 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<BlockTardimScanner> implements IPeripheral {
public class TardimScannerPeripheral extends TardimPeripheral implements IPeripheral {
/**
* @param tileEntity the tile entity of this peripheral
* @hidden
*/
public TardimScannerPeripheral(FakeTardimPeripheralTileEntity tileEntity) {
super(tileEntity, "tardim_scanner", (BlockTardimScanner) tileEntity.getBlock());
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 ===============================================================
@ -114,7 +120,7 @@ public class TardimScannerPeripheral extends TardimPeripheral<BlockTardimScanner
@LuaFunction(mainThread = true)
public final ObjectLuaTable getBiomes() throws LuaException {
Map<Integer, String> biomes = new HashMap<>();
Registry<Biome> biomeRegistry = tileEntity.getLevel().registryAccess().registryOrThrow(Registries.BIOME);
Registry<Biome> biomeRegistry = tileEntity.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
Iterator<ResourceLocation> biome_it = biomeRegistry.keySet().iterator();
int i = 0;
while (biome_it.hasNext()) {

View file

@ -1,28 +1,35 @@
package su.a71.tardim_ic.computercraft_compat.peripherals;
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
import com.swdteam.tardim.common.block.BlockRotor;
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.computercraft_compat.entity.FakeTardimPeripheralTileEntity;
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<BlockRotor> implements IPeripheral {
public class TimeRotorPeripheral extends TardimPeripheral implements IPeripheral {
/**
* @param tileEntity the tile entity of this peripheral
* @hidden
*/
public TimeRotorPeripheral(FakeTardimPeripheralTileEntity tileEntity) {
super(tileEntity, "tardim_rotor", (BlockRotor) tileEntity.getBlock());
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 ===============================================================

View file

@ -0,0 +1,60 @@
package su.a71.tardim_ic.tardim_ic.create_compat.display_source.fuel_storage;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.block.display.source.PercentOrProgressBarDisplaySource;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Lang;
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.minecraft.world.level.block.entity.BlockEntity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import static su.a71.tardim_ic.tardim_ic.Constants.LOG;
public class FuelLevelDisplaySource extends PercentOrProgressBarDisplaySource {
@Override
protected Float getProgress(DisplayLinkContext context) {
if (context.level() != context.level().getServer().getLevel(TRDDimensions.TARDIS)) {
return null;
}
BlockEntity te = context.getSourceTE();
if (!(te instanceof TileEntityFuelStorage fuelStorage))
return null;
TardimData data = TardimManager.getFromPos(fuelStorage.getBlockPos());
LOG.info(String.valueOf((float) (data.getFuel())));
return (float) (data.getFuel() / 100);
}
@Override
protected boolean progressBarActive(DisplayLinkContext context) {
return context.sourceConfig()
.getInt("Mode") != 0;
}
@Override
protected String getTranslationKey() {
return "fuel_level";
}
@Override
@Environment(EnvType.CLIENT)
public void initConfigurationWidgets(DisplayLinkContext context, ModularGuiLineBuilder builder, boolean isFirstLine) {
super.initConfigurationWidgets(context, builder, isFirstLine);
if (isFirstLine)
return;
builder.addSelectionScrollInput(0, 120,
(si, l) -> si.forOptions(Lang.translatedOptions("display_source.fuel_level", "percent", "progress_bar"))
.titled(Lang.translateDirect("display_source.fuel_level.display")),
"Mode");
}
@Override
protected boolean allowsLabeling(DisplayLinkContext context) {
return true;
}
}

View file

@ -0,0 +1,54 @@
package su.a71.tardim_ic.tardim_ic.create_compat.display_source.fuel_storage;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.block.display.source.NumericSingleLineDisplaySource;
import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats;
import com.simibubi.create.foundation.utility.Components;
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.minecraft.network.chat.MutableComponent;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.Vec3;
public class RequiredFuelDisplaySource extends NumericSingleLineDisplaySource {
@Override
protected MutableComponent provideLine(DisplayLinkContext displayLinkContext, DisplayTargetStats displayTargetStats) {
if (displayLinkContext.level() != displayLinkContext.level().getServer().getLevel(TRDDimensions.TARDIS))
return null;
BlockEntity te = displayLinkContext.getSourceTE();
if (!(te instanceof TileEntityFuelStorage fuelStorage))
return null;
TardimData data = TardimManager.getFromPos(fuelStorage.getBlockPos());
if (data.getTravelLocation() == null) return ZERO.copy();
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 Components.literal(String.valueOf(fuel));
}
protected String getTranslationKey() {
return "required_fuel";
}
protected boolean allowsLabeling(DisplayLinkContext context) {
return true;
}
}

View file

@ -1,26 +1,26 @@
package su.a71.tardim_ic.jammer;
package su.a71.tardim_ic.tardim_ic.jammer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import org.jetbrains.annotations.NotNull;
public class PersonalJammerMaterial implements ArmorMaterial {
public class LocationJammerMaterial implements ArmorMaterial {
private static final int[] BASE_DURABILITY = new int[] {13, 15, 16, 11};
private static final int[] PROTECTION_VALUES = new int[] {1, 1, 1, 1};
@Override
public int getDurabilityForType(ArmorItem.Type type) {
return BASE_DURABILITY[type.getSlot().getIndex()] * 33;
public int getDurabilityForSlot(EquipmentSlot slot) {
return BASE_DURABILITY[slot.getIndex()] * 33;
}
@Override
public int getDefenseForType(ArmorItem.Type type) {
return PROTECTION_VALUES[type.getSlot().getIndex()];
public int getDefenseForSlot(EquipmentSlot slot) {
return PROTECTION_VALUES[slot.getIndex()];
}
@Override
@ -41,7 +41,7 @@ public class PersonalJammerMaterial implements ArmorMaterial {
@Override
public @NotNull String getName() {
// Must be all lowercase
return "personal_jammer";
return "location jammer";
}
@Override

View file

@ -1,6 +1,7 @@
package su.a71.tardim_ic.mixin;
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;
@ -8,8 +9,8 @@ import org.spongepowered.asm.mixin.Overwrite;
import static com.swdteam.tardim.tardim.TardimManager.FUEL_MAP;
// This mixin aims to make TARDIM fuel system less awful by allowing users to put standard furnace fuel into it.
@Mixin(value = TardimManager.class, remap = true)
// 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
@ -29,4 +30,13 @@ public class BetterFuelMapMixin {
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)) {
//
// }
// }
}

View file

@ -1,10 +1,11 @@
package su.a71.tardim_ic.mixin;
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;
@ -22,9 +23,9 @@ 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.Constants.LOG;
import static su.a71.tardim_ic.tardim_ic.Constants.LOG;
@Mixin(value = TileEntityFuelStorage.class, remap = true)
@Mixin(value = TileEntityFuelStorage.class, remap = false)
public class BetterFuelStorageMixin {
// This is rather inefficient as we iterate 2 times
@ -33,6 +34,7 @@ public class BetterFuelStorageMixin {
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);

View file

@ -0,0 +1,35 @@
package su.a71.tardim_ic.tardim_ic.mixin;
import com.swdteam.tardim.common.command.tardim.CommandLocate;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager;
import dan200.computercraft.api.lua.LuaException;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
import static com.swdteam.tardim.common.command.tardim.CommandTardimBase.sendResponse;
import static su.a71.tardim_ic.tardim_ic.Constants.LOG;
import static su.a71.tardim_ic.tardim_ic.Registration.LOCATION_JAMMER;
@Mixin(value = CommandLocate.class, remap = false)
public class JammerMixin {
// @Inject(method="execute()V", at=@At(value = "INVOKE", target = "Lcom/swdteam/tardim/tardim/TardimData;setTravelLocation(Lcom/swdteam/tardim/tardim/TardimData$Location;)V"))
// public void execute(CallbackInfo ci) {
// LOG.info("test");
//// for (ItemStack armour : player.getArmorSlots()) {
//// if (armour.is(LOCATION_JAMMER)) {
//// sendResponse(player, "Player's location is jammed", CommandTardimBase.ResponseType.FAIL, source);
//// ci.cancel();
//// };
//// }
// }
}

View file

@ -1,15 +1,16 @@
package su.a71.tardim_ic.command;
package su.a71.tardim_ic.tardim_ic.registration;
import com.swdteam.tardim.common.init.CommandManager;
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.CommandListDimensions;
public class CommandInit {
public static void init() {
CommandManager.register(new CommandCloisterBell());
CommandManager.register(new CommandListBiomes());
CommandManager.register(new CommandListDimensions());
}
public static void addCC() {
CommandManager.register(new CommandModemTransmit());
CommandManager.register(new CommandCloisterBell());
}
}

View file

@ -0,0 +1,36 @@
package su.a71.tardim_ic.tardim_ic.registration;
import com.swdteam.tardim.common.init.CommandManager;
import dan200.computercraft.api.ComputerCraftAPI;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import su.a71.tardim_ic.tardim_ic.Constants;
import su.a71.tardim_ic.tardim_ic.Registration;
import su.a71.tardim_ic.tardim_ic.command.CommandModemTransmit;
import su.a71.tardim_ic.tardim_ic.computercraft_compat.TardimPeripheralProvider;
import su.a71.tardim_ic.tardim_ic.computercraft_compat.blocks.digital_interface.DigitalInterfaceBlock;
import su.a71.tardim_ic.tardim_ic.computercraft_compat.blocks.digital_interface.DigitalInterfaceTileEntity;
public class ComputerCraftCompat {
public static final Block DIGITAL_TARDIM_INTERFACE = new DigitalInterfaceBlock();
public static final BlockEntityType<DigitalInterfaceTileEntity> DIGITAL_TARDIM_INTERFACE_TILEENTITY = Registry.register(
Registry.BLOCK_ENTITY_TYPE,
new ResourceLocation("tardim_ic", "digital_tardim_interface"),
FabricBlockEntityTypeBuilder.create(DigitalInterfaceTileEntity::new, DIGITAL_TARDIM_INTERFACE).build()
);
public static void register() {
Constants.LOG.info("Loaded ComputerCraft compatibility!");
Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "digital_tardim_interface"), DIGITAL_TARDIM_INTERFACE);
Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "digital_tardim_interface"), new BlockItem(DIGITAL_TARDIM_INTERFACE, new FabricItemSettings().tab(Registration.TARDIM_IC_TAB)));
CommandManager.register(new CommandModemTransmit());
ComputerCraftAPI.registerPeripheralProvider(new TardimPeripheralProvider());
}
}

View file

@ -0,0 +1,21 @@
package su.a71.tardim_ic.tardim_ic.registration;
import com.simibubi.create.content.logistics.block.display.AllDisplayBehaviours;
import net.minecraft.resources.ResourceLocation;
import su.a71.tardim_ic.tardim_ic.Constants;
import su.a71.tardim_ic.tardim_ic.create_compat.display_source.fuel_storage.FuelLevelDisplaySource;
import su.a71.tardim_ic.tardim_ic.create_compat.display_source.fuel_storage.RequiredFuelDisplaySource;
import static com.swdteam.tardim.common.init.TRDTiles.TILE_FUEL_STORAGE;
public class CreateCompat {
public static void register() {
Constants.LOG.info("Loaded Create compatibility!");
// Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "digital_tardim_interface"), DIGITAL_TARDIM_INTERFACE);
// Registry.register(Registry.ITEM, new ResourceLocation(Constants.MOD_ID, "digital_tardim_interface"), new BlockItem(DIGITAL_TARDIM_INTERFACE, new FabricItemSettings().tab(Registration.TARDIM_IC_TAB)));
AllDisplayBehaviours.assignTile(AllDisplayBehaviours.register(new ResourceLocation(Constants.MOD_ID, "fuel_storage_display_source"), new FuelLevelDisplaySource()), TILE_FUEL_STORAGE);
AllDisplayBehaviours.assignTile(AllDisplayBehaviours.register(new ResourceLocation(Constants.MOD_ID, "fuel_required_display_source"), new RequiredFuelDisplaySource()), TILE_FUEL_STORAGE);
}
}

View file

@ -11,7 +11,6 @@ import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityT
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.datafix.fixes.References;
import net.minecraft.world.level.block.Block;
@ -20,8 +19,9 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import su.a71.tardim_ic.Constants;
import su.a71.tardim_ic.soviet_chronobox.SovietChronoboxTileEntity;
import net.minecraft.world.level.material.Material;
import su.a71.tardim_ic.tardim_ic.Constants;
import su.a71.tardim_ic.tardim_ic.soviet_chronobox.SovietChronoboxTileEntity;
public class Exteriors {
// Soviet Chronobox
@ -33,11 +33,11 @@ public class Exteriors {
private static <T extends BlockEntity> BlockEntityType<T> createTardimTile(String string, FabricBlockEntityTypeBuilder<T> builder) {
Type<?> type = Util.fetchChoiceType(References.BLOCK_ENTITY, string);
return (BlockEntityType) Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, new ResourceLocation(Constants.MOD_ID, string), builder.build(type));
return (BlockEntityType) Registry.register(Registry.BLOCK_ENTITY_TYPE, new ResourceLocation(Constants.MOD_ID, string), builder.build(type));
}
public static void register() {
FLOOR_SOVIET_CHRONOBOX = Registry.register(BuiltInRegistries.BLOCK, new ResourceLocation(Constants.MOD_ID, "tardim_floor_soviet"), new BlockTardimFloor(FabricBlockSettings.create().sounds(SoundType.WOOD).strength(-1.0F, 3600000.0F).noLootTable().noOcclusion(), new BlockTardimFloor.TardimTileData() {
FLOOR_SOVIET_CHRONOBOX = Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "tardim_floor_soviet"), new BlockTardimFloor(FabricBlockSettings.of(Material.WOOD).sounds(SoundType.WOOD).strength(-1.0F, 3600000.0F).noLootTable().noOcclusion(), new BlockTardimFloor.TardimTileData() {
public BlockEntityType<TileEntityTardim> getType() {
return TILE_SOVIET_CHRONOBOX;
}
@ -49,8 +49,9 @@ public class Exteriors {
}
}));
TILE_SOVIET_CHRONOBOX = createTardimTile("tardim_soviet_chronobox", FabricBlockEntityTypeBuilder.create(SovietChronoboxTileEntity::new, new Block[]{FLOOR_SOVIET_CHRONOBOX}));
DOOR_SOVIET_CHRONOBOX = Registry.register(BuiltInRegistries.BLOCK, new ResourceLocation(Constants.MOD_ID, "tardim_door_soviet"), new BlockTardimDoors(FabricBlockSettings.create().sounds(SoundType.WOOD).strength(-1.0F, 3600000.0F).noLootTable().noOcclusion()));
ROOF_SOVIET_CHRONOBOX = Registry.register(BuiltInRegistries.BLOCK, new ResourceLocation(Constants.MOD_ID, "tardim_roof_soviet"), new BlockTardimRoof(FabricBlockSettings.create().sounds(SoundType.WOOD).strength(-1.0F, 3600000.0F).noLootTable().noOcclusion()));
DOOR_SOVIET_CHRONOBOX = Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "tardim_door_soviet"), new BlockTardimDoors(FabricBlockSettings.of(Material.WOOD).sounds(SoundType.WOOD).strength(-1.0F, 3600000.0F).noLootTable().noOcclusion()));
ROOF_SOVIET_CHRONOBOX = Registry.register(Registry.BLOCK, new ResourceLocation(Constants.MOD_ID, "tardim_roof_soviet"), new BlockTardimRoof(FabricBlockSettings.of(Material.WOOD).sounds(SoundType.WOOD).strength(-1.0F, 3600000.0F).noLootTable().noOcclusion()));
TARDIM_TYPE_SOVIET = new TardimRegistry.TardimBuilder(new ResourceLocation(Constants.MOD_ID, "tardim_soviet_chronobox"), "TARDIM Soviet Chronobox", ROOF_SOVIET_CHRONOBOX, DOOR_SOVIET_CHRONOBOX, FLOOR_SOVIET_CHRONOBOX);
}
}

View file

@ -1,9 +1,10 @@
package su.a71.tardim_ic.soviet_chronobox;
package su.a71.tardim_ic.tardim_ic.soviet_chronobox;
import com.swdteam.tardim.common.init.TRDTiles;
import com.swdteam.tardim.tileentity.TileEntityTardim;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import su.a71.tardim_ic.tardim_ic.Registration;
import su.a71.tardim_ic.tardim_ic.registration.Exteriors;
public class SovietChronoboxTileEntity extends TileEntityTardim {

View file

@ -0,0 +1,40 @@
{
"schemaVersion": 1,
"id": "tardim_ic",
"version": "${version}",
"name": "Tardim: In Control",
"description": "All of time and space, now automated. Control your TARDIM using ComputerCraft: Tweaked.",
"authors": [
"Andrew_7_1"
],
"contact": {
"sources": "https://github.com/Andrew-71/tardim-in-control"
},
"license": "MIT",
"icon": "icon.png",
"environment": "*",
"entrypoints": {
"main": [
"su.a71.tardim_ic.tardim_ic.TardimInControl"
]
},
"mixins": [
"mixins.tardim_ic.json"
],
"depends": {
"fabricloader": ">=0.14.10",
"fabric": "*",
"minecraft": "1.19.x",
"java": ">=17",
"tardim": ">=1.2.2"
},
"suggests": {
"computercraft": ">=1.101.0"
}
}

View file

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

View file

@ -1,27 +1,29 @@
plugins {
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle' version '[6.0.18,6.2)'
id 'org.spongepowered.mixin'
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7.+'
}
}
base {
archivesName = "${mod_name}-forge-${minecraft_version}"
}
mixin {
add(sourceSets.main, "${mod_id}.refmap.json")
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
config("${mod_id}.mixins.json")
config("${mod_id}.forge.mixins.json")
}
archivesBaseName = "${mod_name}-forge-${minecraft_version}"
minecraft {
mappings channel: 'official', version: minecraft_version
// Automatically enable forge AccessTransformers if the file exists
// This location is hardcoded in Forge and can not be changed.
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
if (project.hasProperty('forge_ats_enabled') && project.findProperty('forge_ats_enabled').toBoolean()) {
// This location is hardcoded in Forge and can not be changed.
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
project.logger.debug('Forge Access Transformers are enabled for this project.')
}
runs {
@ -34,7 +36,7 @@ minecraft {
mods {
modClientRun {
source sourceSets.main
source project(":common").sourceSets.main
source project(":Common").sourceSets.main
}
}
}
@ -48,7 +50,7 @@ minecraft {
mods {
modServerRun {
source sourceSets.main
source project(":common").sourceSets.main
source project(":Common").sourceSets.main
}
}
}
@ -63,43 +65,48 @@ minecraft {
mods {
modDataRun {
source sourceSets.main
source project(":common").sourceSets.main
source project(":Common").sourceSets.main
}
}
}
}
}
mixin {
add sourceSets.main, 'refmap.tardim_ic.json'
config 'mixins.tardim_ic.json'
}
sourceSets.main.resources.srcDir 'src/generated/resources'
dependencies {
minecraft "net.neoforged:forge:${minecraft_version}-${neoforged_version}"
compileOnly project(":common")
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor")
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
compileOnly project(":Common")
implementation fg.deobf("curse.maven:tardim-531315:4453925")
implementation fg.deobf("org.squiddev:cc-tweaked-1.19.1:${cc_version}")
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}
tasks.withType(JavaCompile).configureEach {
source(project(":common").sourceSets.main.allSource)
}
tasks.withType(Javadoc).configureEach {
source(project(":common").sourceSets.main.allJava)
}
tasks.named("sourcesJar", Jar) {
from(project(":common").sourceSets.main.allSource)
tasks.withType(JavaCompile) {
source(project(":Common").sourceSets.main.allSource)
}
processResources {
from project(":common").sourceSets.main.resources
from project(":Common").sourceSets.main.resources
}
jar.finalizedBy('reobfJar')
publishing {
publications {
mavenJava(MavenPublication) {
artifactId base.archivesName.get()
from components.java
fg.component(it)
groupId project.group
artifactId project.archivesBaseName
version project.version
artifact jar
}
}
repositories {

View file

@ -0,0 +1,65 @@
package su.a71.tardim_ic.tardim_ic;
import com.google.common.collect.Sets;
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.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
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.redstone_input.RedstoneInputBlock;
import su.a71.tardim_ic.tardim_ic.redstone_input.RedstoneInputTileEntity;
import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
import java.util.function.Supplier;
public class Registration {
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<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") {
@Override
public ItemStack makeIcon() {
return new ItemStack(Registration.DIGITAL_TARDIM_INTERFACE.get());
}
};
// Blocks
private static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block) {
RegistryObject<T> registryObject = BLOCKS.register(name, block);
ITEMS.register(name, () -> new BlockItem(registryObject.get(), new Item.Properties().tab(TARDIM_IC_TAB)));
return registryObject;
}
public static final RegistryObject<Block> DIGITAL_TARDIM_INTERFACE = register("digital_tardim_interface", DigitalInterfaceBlock::new);
public static final RegistryObject<Block> REDSTONE_TARDIM_INPUT = register("redstone_tardim_input", RedstoneInputBlock::new);
// Tile Entities
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));
// Cloister bell
public static final RegistryObject<SoundEvent> CLOISTER_SOUND = SOUNDS.register("cloister", () -> new SoundEvent(new ResourceLocation(TardimInControl.MODID, "cloister")));
// Register our stuff
public static void register() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
BLOCKS.register(modEventBus);
ITEMS.register(modEventBus);
BLOCK_ENTITIES.register(modEventBus);
SOUNDS.register(modEventBus);
}
}

View file

@ -1,10 +1,18 @@
package su.a71.tardim_ic;
package su.a71.tardim_ic.tardim_ic;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
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
@Mod(Constants.MOD_ID)
public class TardimInControl {
// Our mod id
public static final String MODID = Constants.MOD_ID;
public TardimInControl() {
Registration.register();

View file

@ -0,0 +1,59 @@
package su.a71.tardim_ic.tardim_ic.command;
import com.swdteam.common.command.tardim.CommandTardimBase;
import com.swdteam.common.command.tardim.ICommand;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import su.a71.tardim_ic.tardim_ic.Registration;
public class CommandCloisterBell implements ICommand {
@Override
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
if (args.length == 0) {
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
try {
Level lvl = player.getLevel();
if (!lvl.isClientSide) {
lvl.playSound(
null,
pos,
Registration.CLOISTER_SOUND.get(),
SoundSource.BLOCKS,
1.5f,
1f
);
}
} catch (Exception var9) {
CommandTardimBase.sendResponse(player, "There was an error", CommandTardimBase.ResponseType.FAIL, source);
}
} else {
CommandTardimBase.sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
}
}
} else {
CommandTardimBase.sendResponse(player, this.getUsage(), CommandTardimBase.ResponseType.FAIL, source);
}
}
@Override
public String getCommandName() {
return "cloister-bell";
}
@Override
public String getUsage() {
return "/cloister-bell";
}
@Override
public CommandTardimBase.CommandSource allowedSource() {
return CommandTardimBase.CommandSource.BOTH;
}
}

View file

@ -0,0 +1,54 @@
package su.a71.tardim_ic.tardim_ic.command;
import com.swdteam.common.command.tardim.CommandTardimBase;
import com.swdteam.common.command.tardim.ICommand;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.biome.Biome;
public class CommandListBiomes implements ICommand{
@Override
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
;
if (args.length == 1 || args.length == 0) {
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
Registry<Biome> biomeRegistry = player.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
biomeRegistry.keySet().forEach(
(ResourceLocation res) -> {
String out = res.toString();
if (args.length == 0 || (args[0].equals(out.split(":")[0]))) {
CommandTardimBase.sendResponse(player, out, CommandTardimBase.ResponseType.INFO, source);
}
}
);
} else {
CommandTardimBase.sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
}
}
} else {
CommandTardimBase.sendResponse(player, this.getUsage(), CommandTardimBase.ResponseType.FAIL, source);
}
}
@Override
public String getCommandName() {
return "list-biomes";
}
@Override
public String getUsage() {
return "/list-biomes";
}
@Override
public CommandTardimBase.CommandSource allowedSource() {
return CommandTardimBase.CommandSource.BOTH;
}
}

View file

@ -0,0 +1,47 @@
package su.a71.tardim_ic.tardim_ic.command;
import com.swdteam.common.command.tardim.CommandTardimBase;
import com.swdteam.common.command.tardim.ICommand;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
public class CommandListDimensions implements ICommand{
@Override
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
if (args.length == 0) {
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
// TODO: Does this really work?
for (ServerLevel serverLevel : player.getLevel().getServer().getAllLevels()) {
CommandTardimBase.sendResponse(player, serverLevel.dimension().location().toString(), CommandTardimBase.ResponseType.INFO, source);
}
} else {
CommandTardimBase.sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
}
}
} else {
CommandTardimBase.sendResponse(player, this.getUsage(), CommandTardimBase.ResponseType.FAIL, source);
}
}
@Override
public String getCommandName() {
return "list-dimensions";
}
@Override
public String getUsage() {
return "/list-dimensions";
}
@Override
public CommandTardimBase.CommandSource allowedSource() {
return CommandTardimBase.CommandSource.BOTH;
}
}

View file

@ -0,0 +1,69 @@
package su.a71.tardim_ic.tardim_ic.command;
// This will be added whenever I manage to convince TARDIM devs to make CommandManager.register public
// 13.04.23 ITS ALIVE
import com.swdteam.common.command.tardim.CommandTardimBase;
import com.swdteam.common.command.tardim.ICommand;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import dan200.computercraft.api.network.Packet;
import dan200.computercraft.api.ComputerCraftAPI;
public class CommandModemTransmit implements ICommand {
@Override
public void execute(String[] args, Player player, BlockPos pos, CommandTardimBase.CommandSource source) {
if (args.length == 3) { // TODO: 3 or 4???
TardimData data = TardimManager.getFromPos(pos);
if (data != null) {
if (data.hasPermission(player)) {
try {
int sendChannel = Integer.parseInt(args[0]);
int replyChannel = Integer.parseInt(args[1]);
String message = args[2];
boolean allDimensions = Boolean.parseBoolean(args[3]) || args[3].equals("true");
if (data.getTravelLocation() == null) {
data.setTravelLocation(new TardimData.Location(data.getCurrentLocation()));
}
if (allDimensions)
{
ComputerCraftAPI.getWirelessNetwork().transmitInterdimensional(new Packet(sendChannel, replyChannel, message, new CommandSender(player, data.getTravelLocation().getPos())));
}
else {
ComputerCraftAPI.getWirelessNetwork().transmitSameDimension(new Packet(sendChannel, replyChannel, message,
new CommandSender(player, data.getTravelLocation().getPos())), 300);
}
CommandTardimBase.sendResponse(player, "Sent modem message", CommandTardimBase.ResponseType.COMPLETE, source);
} catch (Exception var9) {
CommandTardimBase.sendResponse(player, "Invalid coordinates", CommandTardimBase.ResponseType.FAIL, source);
}
} else {
CommandTardimBase.sendResponse(player, "You do not have permission", CommandTardimBase.ResponseType.FAIL, source);
}
}
} else {
CommandTardimBase.sendResponse(player, this.getUsage(), CommandTardimBase.ResponseType.FAIL, source);
}
}
@Override
public String getCommandName() {
return "cc-modem-transmit";
}
@Override
public String getUsage() {
return "/cc-modem-transmit <Chnl> <replyChnl> <msg> <ender: bool>";
}
@Override
public CommandTardimBase.CommandSource allowedSource() {
return CommandTardimBase.CommandSource.BOTH;
}
}

View file

@ -0,0 +1,40 @@
package su.a71.tardim_ic.tardim_ic.command;
import dan200.computercraft.api.network.IPacketSender;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
public class CommandSender implements IPacketSender {
private final Player player;
private final Level level;
private final BlockPos pos;
CommandSender(Player player, BlockPos pos) {
this.player = player;
this.level = player.level;
this.pos = pos;
}
@NotNull
@Override
public Level getLevel() {
return this.level;
}
@NotNull
@Override
public Vec3 getPosition() {
return new Vec3(this.pos.getX(), this.pos.getY(), this.pos.getZ());
}
@NotNull
@Override
public String getSenderID() {
return this.player.getName().getString();
}
}

View file

@ -0,0 +1,27 @@
package su.a71.tardim_ic.tardim_ic.digital_interface;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import org.jetbrains.annotations.NotNull;
import su.a71.tardim_ic.tardim_ic.Registration;
import javax.annotation.Nullable;
public class DigitalInterfaceBlock extends Block implements EntityBlock {
public DigitalInterfaceBlock() {
super(Properties.of(Material.METAL).strength(2, 4).noOcclusion());
}
@Nullable
@Override
public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
return Registration.DIGITAL_TARDIM_INTERFACE_TILEENTITY.get().create(pos, state);
}
}

Some files were not shown because too many files have changed in this diff Show more