Begin 1.20 port (god this is horrible)

This commit is contained in:
Andrew-71 2023-07-29 21:07:20 +03:00
parent 8730ae91a0
commit 987a18c360
105 changed files with 757 additions and 2300 deletions

View file

@ -1,3 +1,5 @@
TODO: Rewrite for 1.20
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.

View file

@ -1,66 +1,34 @@
plugins {
id 'idea'
id 'java'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
id 'maven-publish'
id 'org.spongepowered.gradle.vanilla'
}
base {
archivesName = "${mod_name}-common-${minecraft_version}"
}
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"
}
if(file("src/main/resources/${mod_id}.accesswidener").exists()){
accessWideners(file("src/main/resources/${mod_id}.accesswidener"))
}
}
dependencies {
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
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
}
// ComputerCraft
compileOnly("cc.tweaked:cc-tweaked-$minecraft_version-common-api:$cc_version")
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
artifactId base.archivesName.get()
from components.java
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")

View file

@ -0,0 +1,11 @@
package su.a71.tardim_ic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Constants {
public static final String MOD_ID = "tardim_ic";
public static final String MOD_NAME = "TARDIM: In Control";
public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME);
}

View file

@ -0,0 +1,8 @@
package su.a71.tardim_ic;
public class Registration {
public static void register() {
}
}

View file

@ -0,0 +1,25 @@
package su.a71.tardim_ic.platform;
import com.example.examplemod.Constants;
import su.a71.tardim_ic.platform.services.IPlatformHelper;
import java.util.ServiceLoader;
public class Services {
// Platform helper that lets us do stuff for Forge/Fabric while being in Common
public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class);
// This code is used to load a service for the current environment. Your implementation of the service must be defined
// manually by including a text file in META-INF/services named with the fully qualified class name of the service.
// Inside the file you should write the fully qualified class name of the implementation to load for the platform. For
// example our file on Forge points to ForgePlatformHelper while Fabric points to FabricPlatformHelper.
public static <T> T load(Class<T> clazz) {
final T loadedService = ServiceLoader.load(clazz)
.findFirst()
.orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName()));
Constants.LOG.debug("Loaded {} for service {}", loadedService, clazz);
return loadedService;
}
}

View file

@ -0,0 +1,38 @@
package su.a71.tardim_ic.platform.services;
public interface IPlatformHelper {
/**
* Gets the name of the current platform
*
* @return The name of the current platform.
*/
String getPlatformName();
/**
* Checks if a mod with the given id is loaded.
*
* @param modId The mod to check if it is loaded.
* @return True if the mod is loaded, false otherwise.
*/
boolean isModLoaded(String modId);
/**
* Check if the game is currently in a development environment.
*
* @return True if in a development environment, false otherwise.
*/
boolean isDevelopmentEnvironment();
/**
* Gets the name of the environment type as a string.
*
* @return The name of the environment type.
*/
default String getEnvironmentName() {
return isDevelopmentEnvironment() ? "development" : "production";
}
// TODO: Add registration stuff here?
}

View file

@ -1,19 +0,0 @@
package su.a71.tardim_ic.tardim_ic;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Constants {
public static final String MOD_ID = "tardim_ic";
public static final String MOD_NAME = "TARDIM: In Control";
public static final Logger LOG;
public static final Gson GSON;
static {
LOG = LoggerFactory.getLogger(MOD_NAME);
GSON = (new GsonBuilder()).setPrettyPrinting().create();
}
}

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.utils;
package su.a71.tardim_ic.utils;
import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPos;
@ -7,14 +7,18 @@ 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"), null);
super(lvl, blockPos, 0, new GameProfile(UUID.randomUUID(), "FakePlayer_tardimic"));
}
public FakePlayer(Level lvl, BlockPos blockPos, UUID id) {
super(lvl, blockPos, 0, new GameProfile(id, "FakePlayer_tardimic"), null);
super(lvl, blockPos, 0, new GameProfile(id, "FakePlayer_tardimic"));
}
@ -28,5 +32,3 @@ public class FakePlayer extends Player {
return false;
}
}

View file

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

View file

@ -3,8 +3,8 @@
"parent": "digital_tardim_interface",
"texture_size": [64, 64],
"textures": {
"1": "tardim_ic:blocks/digital_tardim_interface",
"particle": "tardim_ic:blocks/digital_tardim_interface"
"1": "tardim_ic:block/digital_tardim_interface",
"particle": "tardim_ic:block/digital_tardim_interface"
},
"elements": [
{

View file

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

View file

@ -3,9 +3,9 @@
"parent": "block/cube_all",
"ambientocclusion": false,
"textures": {
"1": "tardim_ic:blocks/red_contr",
"2": "tardim_ic:blocks/red_contr2",
"particle": "tardim_ic:blocks/red_contr"
"1": "tardim_ic:block/redstone_input",
"2": "tardim_ic:block/redstone_input",
"particle": "tardim_ic:block/redstone_input"
},
"elements": [
{

View file

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

View file

@ -0,0 +1,7 @@
{
"animation": {
"frametime": 10,
"interpolate": true,
"frames": [0, 1, 2, 3]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 923 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

View file

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

View file

@ -0,0 +1,20 @@
{
"required": true,
"minVersion": "0.8",
"package": "su.a71.tardim_ic.mixin",
"refmap": "${mod_id}.refmap.json",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
],
"server": [
"BetterFuelMapMixin",
"BetterFuelStorageMixin",
"JammerMixin"
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -1,36 +1,32 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
id 'java'
id 'idea'
id 'maven-publish'
id 'fabric-loom'
}
base {
archivesName = "${mod_name}-fabric-${minecraft_version}"
}
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")
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:4597892"
// Obfuscation forced my hand, TARDIM will be here for now :/
modImplementation(files("/Users/andreynikitin/Downloads/tardim.jar"))
modCompileOnly("cc.tweaked:cc-tweaked-$minecraft_version-fabric-api:$cc_version")
}
loom {
if (project(":common").file("src/main/resources/${mod_id}.accesswidener").exists()) {
accessWidenerPath.set(project(":common").file("src/main/resources/${mod_id}.accesswidener"))
}
mixin {
defaultRefmapName.set("${mod_id}.refmap.json")
}
runs {
client {
client()
@ -47,30 +43,27 @@ loom {
}
}
processResources {
from project(":Common").sourceSets.main.resources
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
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
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
artifactId base.archivesName.get()
from components.java
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")

View file

@ -0,0 +1,18 @@
package com.example.examplemod;
import net.fabricmc.api.ModInitializer;
public class ExampleMod implements ModInitializer {
@Override
public void onInitialize() {
// This method is invoked by the Fabric mod loader when it is ready
// to load your mod. You can access Fabric and Common code in this
// project.
// Use Fabric to bootstrap the Common mod.
Constants.LOG.info("Hello Fabric world!");
CommonClass.init();
}
}

View file

@ -0,0 +1,20 @@
package com.example.examplemod.mixin;
import com.example.examplemod.Constants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.TitleScreen;
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;
@Mixin(TitleScreen.class)
public class MixinTitleScreen {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
Constants.LOG.info("This line is printed by an example mod mixin from Fabric!");
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
}
}

View file

@ -0,0 +1,24 @@
package com.example.examplemod.platform;
import com.example.examplemod.platform.services.IPlatformHelper;
import net.fabricmc.loader.api.FabricLoader;
public class FabricPlatformHelper implements IPlatformHelper {
@Override
public String getPlatformName() {
return "Fabric";
}
@Override
public boolean isModLoaded(String modId) {
return FabricLoader.getInstance().isModLoaded(modId);
}
@Override
public boolean isDevelopmentEnvironment() {
return FabricLoader.getInstance().isDevelopmentEnvironment();
}
}

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic;
package su.a71.tardim_ic;
import net.fabricmc.api.ModInitializer;

View file

@ -1,19 +1,13 @@
package su.a71.tardim_ic.tardim_ic.blocks.food_machine;
package su.a71.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;
@ -29,25 +23,20 @@ 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.level.material.MapColor;
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 su.a71.tardim_ic.Registration;
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?
super(Properties.of().strength(2, 4).noOcclusion().mapColor(MapColor.METAL)); // No occlusion?
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
//this.registerDefaultState(this.stateDefinition.any().setValue(HORIZONTAL_FACING, Direction.NORTH));
}

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.blocks.food_machine;
package su.a71.tardim_ic.blocks.food_machine;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
@ -7,7 +7,7 @@ import net.minecraft.world.item.Items;
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 su.a71.tardim_ic.Registration;
import java.util.UUID;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.blocks.redstone_input;
package su.a71.tardim_ic.blocks.redstone_input;
import com.swdteam.tardim.common.block.BlockBaseTardimPanel;
import com.swdteam.tardim.common.init.TRDDimensions;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.blocks.redstone_input;
package su.a71.tardim_ic.blocks.redstone_input;
import com.swdteam.tardim.tileentity.TileEntityBaseTardimPanel;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.command;
package su.a71.tardim_ic.command;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.common.command.tardim.ICommand;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.command;
package su.a71.tardim_ic.command;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.common.command.tardim.ICommand;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.command;
package su.a71.tardim_ic.command;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;
import com.swdteam.tardim.common.command.tardim.ICommand;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.command;
package su.a71.tardim_ic.command;
// This will be added whenever I manage to convince TARDIM devs to make CommandManager.register public
// 13.04.23 ITS ALIVE

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.command;
package su.a71.tardim_ic.command;
import dan200.computercraft.api.network.IPacketSender;
import net.minecraft.core.BlockPos;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.computercraft_compat;
package su.a71.tardim_ic.computercraft_compat;
import com.swdteam.tardim.tardim.TardimData;
import com.swdteam.tardim.tardim.TardimManager;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.computercraft_compat;
package su.a71.tardim_ic.computercraft_compat;
import com.swdteam.tardim.tardim.TardimData;
import net.minecraft.core.BlockPos;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.computercraft_compat;
package su.a71.tardim_ic.computercraft_compat;
import com.swdteam.tardim.common.block.BlockFuelStorage;
import com.swdteam.tardim.common.block.BlockRotor;
@ -10,11 +10,11 @@ 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;
import su.a71.tardim_ic.computercraft_compat.peripherals.TimeRotorPeripheral;
import su.a71.tardim_ic.computercraft_compat.peripherals.FuelStoragePeripheral;
import su.a71.tardim_ic.computercraft_compat.peripherals.TardimScannerPeripheral;
import su.a71.tardim_ic.computercraft_compat.blocks.digital_interface.DigitalInterfaceBlock;
import su.a71.tardim_ic.computercraft_compat.peripherals.DigitalInterfacePeripheral;
public class TardimPeripheralProvider implements IPeripheralProvider {
@Override

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.computercraft_compat.blocks.digital_interface;
package su.a71.tardim_ic.computercraft_compat.blocks.digital_interface;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.computercraft_compat.blocks.digital_interface;
package su.a71.tardim_ic.computercraft_compat.blocks.digital_interface;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntity;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
package su.a71.tardim_ic.computercraft_compat.peripherals;
import com.swdteam.tardim.common.command.tardim.CommandTravel;
import com.swdteam.tardim.common.data.DimensionMapReloadListener;
@ -20,6 +20,7 @@ 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;
@ -34,10 +35,10 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.phys.Vec3;
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.PERSONAL_JAMMER;
import su.a71.tardim_ic.computercraft_compat.FakeTardimPeripheralTileEntity;
import su.a71.tardim_ic.Registration;
import su.a71.tardim_ic.utils.FakePlayer;
import static su.a71.tardim_ic.Registration.PERSONAL_JAMMER;
import javax.annotation.Nonnull;
import java.util.*;
@ -761,7 +762,7 @@ public class DigitalInterfacePeripheral extends TardimPeripheral implements IPer
@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);
Registry<Biome> biomeRegistry = tileEntity.getLevel().registryAccess().registryOrThrow(Registries.BIOME);
Iterator<ResourceLocation> biome_it = biomeRegistry.keySet().iterator();
int i = 0;
while (biome_it.hasNext()) {

View file

@ -1,11 +1,11 @@
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
package su.a71.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 su.a71.tardim_ic.computercraft_compat.FakeTardimPeripheralTileEntity;
import javax.annotation.Nonnull;

View file

@ -1,10 +1,10 @@
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
package su.a71.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 su.a71.tardim_ic.computercraft_compat.ITardimPeripheralTileEntity;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
package su.a71.tardim_ic.computercraft_compat.peripherals;
import com.swdteam.tardim.common.init.TardimRegistry;
import com.swdteam.tardim.tardim.TardimData;
@ -7,11 +7,12 @@ 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.tardim_ic.computercraft_compat.FakeTardimPeripheralTileEntity;
import su.a71.tardim_ic.computercraft_compat.FakeTardimPeripheralTileEntity;
import javax.annotation.Nonnull;
import java.util.HashMap;
@ -120,7 +121,7 @@ public class TardimScannerPeripheral extends TardimPeripheral implements IPeriph
@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);
Registry<Biome> biomeRegistry = tileEntity.getLevel().registryAccess().registryOrThrow(Registries.BIOME);
Iterator<ResourceLocation> biome_it = biomeRegistry.keySet().iterator();
int i = 0;
while (biome_it.hasNext()) {

View file

@ -1,11 +1,11 @@
package su.a71.tardim_ic.tardim_ic.computercraft_compat.peripherals;
package su.a71.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 su.a71.tardim_ic.computercraft_compat.FakeTardimPeripheralTileEntity;
import javax.annotation.Nonnull;
import java.util.Map;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.create_compat.display_source.fuel_storage;
package su.a71.tardim_ic.display_source.fuel_storage;
import com.simibubi.create.content.redstone.displayLink.DisplayLinkContext;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.create_compat.display_source.fuel_storage;
package su.a71.tardim_ic.display_source.fuel_storage;
import com.simibubi.create.content.redstone.displayLink.DisplayLinkContext;
import com.simibubi.create.content.redstone.displayLink.source.NumericSingleLineDisplaySource;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.jammer;
package su.a71.tardim_ic.jammer;
import net.minecraft.sounds.SoundEvent;

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.mixin;
package su.a71.tardim_ic.mixin;
import com.swdteam.tardim.tardim.TardimManager;
import com.swdteam.tardim.tileentity.TileEntityFuelStorage;
@ -10,14 +10,22 @@ 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)
@Mixin(value = TardimManager.class, remap = true)
public class BetterFuelMapMixin {
/**
* @author Andrew_7_1
* @reason The original function is too small to bother with insert
*/
@Overwrite
public static boolean isFuel(Item i) {
return FUEL_MAP.containsKey(i) || AbstractFurnaceBlockEntity.getFuel().containsKey(i);
}
/**
* @author Andrew_7_1
* @reason The code change is drastic enough to warrant an overwrite
*/
@Overwrite
public static double getFuel(Item i) {
if (!isFuel(i)) {
@ -30,13 +38,4 @@ 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,11 +1,10 @@
package su.a71.tardim_ic.tardim_ic.mixin;
package su.a71.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;
@ -23,7 +22,7 @@ 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;
import static su.a71.tardim_ic.Constants.LOG;
@Mixin(value = TileEntityFuelStorage.class, remap = false)
public class BetterFuelStorageMixin {

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.mixin;
package su.a71.tardim_ic.mixin;
import com.swdteam.tardim.common.command.tardim.CommandLocate;
import com.swdteam.tardim.common.command.tardim.CommandTardimBase;

View file

@ -0,0 +1,24 @@
package su.a71.tardim_ic.platform;
import com.example.examplemod.platform.services.IPlatformHelper;
import net.fabricmc.loader.api.FabricLoader;
public class FabricPlatformHelper implements IPlatformHelper {
@Override
public String getPlatformName() {
return "Fabric";
}
@Override
public boolean isModLoaded(String modId) {
return FabricLoader.getInstance().isModLoaded(modId);
}
@Override
public boolean isDevelopmentEnvironment() {
return FabricLoader.getInstance().isDevelopmentEnvironment();
}
}

View file

@ -1,4 +1,4 @@
package su.a71.tardim_ic.tardim_ic.soviet_chronobox;
package su.a71.tardim_ic.soviet_chronobox;
import com.swdteam.tardim.common.init.TRDTiles;
import com.swdteam.tardim.tileentity.TileEntityTardim;

View file

@ -1,78 +0,0 @@
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 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.PersonalJammerMaterial;
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 PERSONAL_JAMMER_MATERIAL = new PersonalJammerMaterial();
public static final Item PERSONAL_JAMMER = new ArmorItem(PERSONAL_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, "personal_jammer"), PERSONAL_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 Item.Properties().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 Item.Properties().tab(TARDIM_IC_TAB)));
Registry.register(Registry.SOUND_EVENT, CLOISTER_SOUND, CLOISTER_SOUND_EVENT);
CommandInit.init();
}
}

View file

@ -3,9 +3,9 @@ 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;
import su.a71.tardim_ic.command.CommandCloisterBell;
import su.a71.tardim_ic.command.CommandListBiomes;
import su.a71.tardim_ic.command.CommandListDimensions;
public class CommandInit {
public static void init() {

View file

@ -11,10 +11,10 @@ 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;
import su.a71.tardim_ic.command.CommandModemTransmit;
import su.a71.tardim_ic.computercraft_compat.TardimPeripheralProvider;
import su.a71.tardim_ic.computercraft_compat.blocks.digital_interface.DigitalInterfaceBlock;
import su.a71.tardim_ic.computercraft_compat.blocks.digital_interface.DigitalInterfaceTileEntity;
public class ComputerCraftCompat {
public static final Block DIGITAL_TARDIM_INTERFACE = new DigitalInterfaceBlock();

View file

@ -4,8 +4,8 @@ package su.a71.tardim_ic.tardim_ic.registration;
import com.simibubi.create.content.redstone.displayLink.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 su.a71.tardim_ic.display_source.fuel_storage.FuelLevelDisplaySource;
import su.a71.tardim_ic.display_source.fuel_storage.RequiredFuelDisplaySource;
import static com.swdteam.tardim.common.init.TRDTiles.TILE_FUEL_STORAGE;

View file

@ -21,7 +21,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
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;
import su.a71.tardim_ic.soviet_chronobox.SovietChronoboxTileEntity;
public class Exteriors {
// Soviet Chronobox

View file

@ -0,0 +1 @@
com.example.examplemod.platform.FabricPlatformHelper

View file

@ -2,40 +2,35 @@
"schemaVersion": 1,
"id": "tardim_ic",
"version": "${version}",
"name": "Tardim: In Control",
"description": "All of time and space, now automated and improved. This mod aims to make TARDIM even better.",
"name": "${mod_name}",
"description": "All of time and space, now automated and improved. This mod aims to improve your TARDIM experience",
"authors": [
"Andrew_7_1"
"${mod_author}"
],
"contact": {
"sources": "https://github.com/Andrew-71/tardim-in-control"
"homepage": "https://tardim.a71.su/",
"sources": "https://github.com/Andrew-71/tardim-in-control"
},
"license": "MIT",
"icon": "icon.png",
"icon": "assets/tardim_ic/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"su.a71.tardim_ic.tardim_ic.TardimInControl"
]
"main": [
"su.a71.tardim_ic.TardimInControl"
]
},
"mixins": [
"mixins.tardim_ic.json"
],
"mixins": [
"tardim_ic.mixins.json",
"tardim_ic.fabric.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.10",
"fabric": "*",
"minecraft": "1.19.x",
"java": ">=17",
"tardim": ">=1.2.2"
"fabricloader": ">=0.14",
"fabric": "*",
"minecraft": "1.20",
"java": ">=17",
"tardim": ">=1.2.2"
},
"suggests": {
"computercraft": ">=1.101.0",
"create": ">=0.5.1"
}
}
"suggests": {
"computercraft": ">=${cc_version}"
}
}

View file

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

View file

@ -0,0 +1,18 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.example.examplemod.mixin",
"refmap": "${mod_id}.refmap.json",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"MixinTitleScreen"
],
"server": [
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -1,29 +1,27 @@
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.+'
}
plugins {
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle'
id 'org.spongepowered.mixin'
}
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
base {
archivesName = "${mod_name}-forge-${minecraft_version}"
}
mixin {
add(sourceSets.main, "${mod_id}.refmap.json")
archivesBaseName = "${mod_name}-forge-${minecraft_version}"
config("${mod_id}.mixins.json")
config("${mod_id}.forge.mixins.json")
}
minecraft {
mappings channel: 'official', version: minecraft_version
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
// 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()) {
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
project.logger.debug('Forge Access Transformers are enabled for this project.')
}
runs {
@ -36,7 +34,7 @@ minecraft {
mods {
modClientRun {
source sourceSets.main
source project(":Common").sourceSets.main
source project(":common").sourceSets.main
}
}
}
@ -50,7 +48,7 @@ minecraft {
mods {
modServerRun {
source sourceSets.main
source project(":Common").sourceSets.main
source project(":common").sourceSets.main
}
}
}
@ -65,48 +63,43 @@ 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.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'
compileOnly project(":common")
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor")
}
tasks.withType(JavaCompile) {
source(project(":Common").sourceSets.main.allSource)
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)
}
processResources {
from project(":Common").sourceSets.main.resources
from project(":common").sourceSets.main.resources
}
jar.finalizedBy('reobfJar')
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
artifact jar
artifactId base.archivesName.get()
from components.java
fg.component(it)
}
}
repositories {

View file

@ -0,0 +1,19 @@
package com.example.examplemod;
import net.minecraftforge.fml.common.Mod;
@Mod(Constants.MOD_ID)
public class ExampleMod {
public ExampleMod() {
// This method is invoked by the Forge mod loader when it is ready
// to load your mod. You can access Forge and Common code in this
// project.
// Use Forge to bootstrap the Common mod.
Constants.LOG.info("Hello Forge world!");
CommonClass.init();
}
}

View file

@ -0,0 +1,20 @@
package com.example.examplemod.mixin;
import com.example.examplemod.Constants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.TitleScreen;
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;
@Mixin(TitleScreen.class)
public class MixinTitleScreen {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
Constants.LOG.info("This line is printed by an example mod mixin from Forge!");
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
}
}

View file

@ -0,0 +1,26 @@
package com.example.examplemod.platform;
import com.example.examplemod.platform.services.IPlatformHelper;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.FMLLoader;
public class ForgePlatformHelper implements IPlatformHelper {
@Override
public String getPlatformName() {
return "Forge";
}
@Override
public boolean isModLoaded(String modId) {
return ModList.get().isLoaded(modId);
}
@Override
public boolean isDevelopmentEnvironment() {
return !FMLLoader.isProduction();
}
}

View file

@ -1,15 +1,10 @@
package su.a71.tardim_ic.tardim_ic;
package su.a71.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 {
public TardimInControl() {
Registration.register();

View file

@ -0,0 +1,26 @@
package su.a71.tardim_ic.platform;
import com.example.examplemod.platform.services.IPlatformHelper;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.FMLLoader;
public class ForgePlatformHelper implements IPlatformHelper {
@Override
public String getPlatformName() {
return "Forge";
}
@Override
public boolean isModLoaded(String modId) {
return ModList.get().isLoaded(modId);
}
@Override
public boolean isDevelopmentEnvironment() {
return !FMLLoader.isProduction();
}
}

View file

@ -1,64 +0,0 @@
package su.a71.tardim_ic.tardim_ic;
import com.google.common.collect.Sets;
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 java.util.function.Supplier;
public class Registration {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Constants.MOD_ID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Constants.MOD_ID);
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, Constants.MOD_ID);
public static final DeferredRegister<SoundEvent> SOUNDS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, Constants.MOD_ID);
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(Constants.MOD_ID, "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,59 +0,0 @@
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

@ -1,54 +0,0 @@
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

@ -1,47 +0,0 @@
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

@ -1,69 +0,0 @@
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

@ -1,40 +0,0 @@
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

@ -1,27 +0,0 @@
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);
}
}

View file

@ -1,887 +0,0 @@
package su.a71.tardim_ic.tardim_ic.digital_interface;
import com.mojang.datafixers.util.Pair;
import com.swdteam.common.command.tardim.CommandTardimBase;
import com.swdteam.common.command.tardim.CommandTravel;
import com.swdteam.common.data.DimensionMapReloadListener;
import com.swdteam.common.init.TRDSounds;
import com.swdteam.common.init.TardimRegistry;
import com.swdteam.common.item.ItemTardim;
import com.swdteam.main.Tardim;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimData.Location;
import com.swdteam.tardim.TardimManager;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.lua.ObjectLuaTable;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
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.levelgen.Heightmap;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.client.DimensionSpecialEffectsManager;
import su.a71.tardim_ic.tardim_ic.Registration;
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
public class DigitalInterfacePeripheral implements IPeripheral {
private final List<IComputerAccess> connectedComputers = new ArrayList<>(); // List of computers connected to the peripheral
private final IDigitalInterfaceEntity tileEntity; // Peripheral's BlockEntity, used for accessing coordinates
/**
* @param tileEntity the tile entity of this peripheral
* @hidden
*/
public DigitalInterfacePeripheral(IDigitalInterfaceEntity tileEntity) {
this.tileEntity = 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"; }
/** 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 ===============================================================
/**
* 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;
Location curr = data.getCurrentLocation();
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;
}
/**
* Check whether the TARDIM is locked
* @return true if locked, false if not
*/
@LuaFunction(mainThread = true)
public final boolean isLocked() throws LuaException {
return getTardimData().isLocked();
}
/**
* 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 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();
}
/**
* Lock/unlock the TARDIM
* @param locked true to lock, false to unlock
*/
@LuaFunction(mainThread = true)
public final void setLocked(boolean locked) throws LuaException {
getTardimData().setLocked(locked);
}
/**
* 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 {
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());
}
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()
));
}
/**
* 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);
}
/**
* Set dimension for the TARDIM to travel to
* <p>
* This is a serious hazard right now due to the fact that I am unable to check if the dimension is valid.
* <p>
* TODO: If invalid dimension is given, the TARDIM is unable to land until the dimension is changed. Add proper checks.
* @param dimension String of the dimension e.g. "minecraft:overworld"
*/
@LuaFunction(mainThread = true)
public final void setDimension(String dimension) throws LuaException {
TardimData data = getTardimData();
String key = dimension;
dimension = DimensionMapReloadListener.toTitleCase(dimension);
if (TardimManager.DIMENSION_MAP.containsKey(dimension)) {
key = (String)TardimManager.DIMENSION_MAP.get(dimension);
} else {
dimension = dimension.toLowerCase();
}
if (!CommandTravel.isValidPath(key)) {
throw new LuaException("Invalid dimension");
} else {
ResourceKey<Level> dim = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(dimension));
if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation()));
}
data.getTravelLocation().setLocation(dim);
}
}
/**
* Set the destination's coordinates
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
*/
@LuaFunction(mainThread = true)
public final void setTravelLocation(int x, int y, int z) throws LuaException {
TardimData data = getTardimData();
if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation()));
}
data.getTravelLocation().setPosition(x, y, z);
}
/**
* Set destination to the TARDIM's owner's home (Must be online)
*/
@LuaFunction(mainThread = true)
public final void home() throws LuaException {
if (this.tileEntity.getLevel().isClientSide()) {
return;
}
TardimData data = getTardimData();
UUID uuid = data.getOwner();
String username = data.getOwnerName();
if (uuid == null || username == null) {
throw new LuaException("TARDIM has no owner");
}
PlayerList playerList = this.tileEntity.getLevel().getServer().getPlayerList();
ServerPlayer player = playerList.getPlayer(uuid);
if (player == null) {
throw new LuaException("TARDIM owner is not online");
}
ResourceKey<Level> dim = player.getRespawnDimension();
BlockPos pos = player.getRespawnPosition();
if (pos == null) {
throw new LuaException("TARDIM owner has no home");
}
setDimension(dim.location().toString());
setTravelLocation(pos.getX(), pos.getY(), pos.getZ());
}
/**
* Set destination for a player's location (Player must be online)
* @param username - String of the username of the player
*/
@LuaFunction(mainThread = true)
public final void locatePlayer(String username) throws LuaException {
if (this.tileEntity.getLevel().isClientSide()) {
return;
}
PlayerList playerList = this.tileEntity.getLevel().getServer().getPlayerList();
ServerPlayer player = playerList.getPlayerByName(username);
if (player == null) {
throw new LuaException("Player not found");
}
ResourceKey<Level> dim = player.getCommandSenderWorld().dimension();
BlockPos pos = player.blockPosition();
setDimension(dim.location().toString());
setTravelLocation(pos.getX(), pos.getY(), pos.getZ());
}
/**
* 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 the rotation of the TARDIM's door
* @return String of the door rotation ("north", "south", "east", "west")
*/
@LuaFunction(mainThread = true)
public final String getDoorRotation() throws LuaException {
TardimData data = getTardimData();
Direction rotation = data.getTravelLocation().getFacing();
switch (rotation) {
case NORTH -> {
return "north";
}
case EAST -> {
return "east";
}
case SOUTH -> {
return "south";
}
case WEST -> {
return "west";
}
default -> {
throw new LuaException("Invalid door rotation");
}
}
}
/**
* Set the rotation of the TARDIM's door
* @param rotation String of the door rotation ("north", "south", "east", "west")
*/
@LuaFunction(mainThread = true)
public final void setDoorRotation(String rotation) throws LuaException {
TardimData data = getTardimData();
switch (rotation) {
case "north" -> data.getTravelLocation().setFacing(Direction.NORTH);
case "east" -> data.getTravelLocation().setFacing(Direction.EAST);
case "south" -> data.getTravelLocation().setFacing(Direction.SOUTH);
case "west" -> data.getTravelLocation().setFacing(Direction.WEST);
default -> throw new LuaException("Invalid door rotation");
}
data.save();
}
/**
* Toggle the rotation of the TARDIM's door (north -> east -> south -> west -> north)
*/
@LuaFunction(mainThread = true)
public final void toggleDoorRotation() throws LuaException {
TardimData data = getTardimData();
if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation()));
}
if (data.getTravelLocation().getFacing() == null) {
data.getTravelLocation().setFacing(Direction.NORTH);
}
switch (data.getTravelLocation().getFacing()) {
case NORTH -> data.getTravelLocation().setFacing(Direction.EAST);
case EAST -> data.getTravelLocation().setFacing(Direction.SOUTH);
case SOUTH -> data.getTravelLocation().setFacing(Direction.WEST);
case WEST -> data.getTravelLocation().setFacing(Direction.NORTH);
default -> data.getTravelLocation().setFacing(Direction.NORTH);
}
data.save();
}
/**
* Add a number to the destination's coordinates
* @param axis String of the axis ("x", "y", "z")
* @param amount Number to add to the axis
*/
@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()));
}
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");
}
}
/**
* Dematerialize the TARDIM
*/
@LuaFunction(mainThread = true)
public final void demat() throws LuaException {
if (this.tileEntity.getLevel().isClientSide()) {
return;
}
TardimData data = getTardimData();
if (data.isInFlight()) {
throw new LuaException("TARDIM is already in flight");
}
Location loc = data.getCurrentLocation();
ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(loc.getLevel());
ItemTardim.destroyTardim(level, loc.getPos(), Direction.NORTH);
data.setInFlight(true);
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(Registry.DIMENSION_REGISTRY, new ResourceLocation(level_str))).playSound(null, this.tileEntity.getPos(), (SoundEvent) TRDSounds.TARDIM_TAKEOFF.get(), SoundSource.AMBIENT, 1.0F, 1.0F);
data.save();
}
/**
* Materialize the TARDIM at the destination
* <p>
* Has a LOT of checks to make sure the TARDIM can materialize, so please implement error handling if you use this.
*/
@LuaFunction(mainThread = true)
public final void remat() throws LuaException {
if (this.tileEntity.getLevel().isClientSide()) {
return;
}
TardimData data = getTardimData();
if (data.isInFlight()) {
if (data.getTimeEnteredFlight() < System.currentTimeMillis() / 1000L - 10L) {
Location loc = data.getTravelLocation();
ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(loc.getLevel());
double fuel = data.calculateFuelForJourney(
this.tileEntity.getLevel().getServer().getLevel(data.getCurrentLocation().getLevel()), level, data.getCurrentLocation().getPos(), loc.getPos()
);
if (data.getFuel() >= fuel) {
level.getChunk(loc.getPos());
BlockPos landingPosButBetter = CommandTravel.getLandingPosition(level, loc.getPos());
boolean recalc = false;
for(int jj = 0; jj < 32; ++jj) {
if (!Block.canSupportRigidBlock(level, landingPosButBetter.below())) {
BlockPos pos2 = landingPosButBetter.offset(
level.random.nextInt(10) * (level.random.nextBoolean() ? 1 : -1),
0,
level.random.nextInt(10) * (level.random.nextBoolean() ? 1 : -1)
);
landingPosButBetter = CommandTravel.getLandingPosition(level, pos2);
if (Block.canSupportRigidBlock(level, landingPosButBetter.below())) {
recalc = true;
break;
}
}
}
if (!recalc) {
for(int jj = 0; jj < 32; ++jj) {
if (!Block.canSupportRigidBlock(level, landingPosButBetter.below())) {
BlockPos pos2 = landingPosButBetter.offset(
level.random.nextInt(30) * (level.random.nextBoolean() ? 1 : -1),
0,
level.random.nextInt(30) * (level.random.nextBoolean() ? 1 : -1)
);
landingPosButBetter = CommandTravel.getLandingPosition(level, pos2);
if (Block.canSupportRigidBlock(level, landingPosButBetter.below())) {
recalc = true;
break;
}
}
}
}
if (!recalc) {
for(int jj = 0; jj < 32; ++jj) {
if (!Block.canSupportRigidBlock(level, landingPosButBetter.below())) {
BlockPos pos2 = landingPosButBetter.offset(
level.random.nextInt(50) * (level.random.nextBoolean() ? 1 : -1),
0,
level.random.nextInt(50) * (level.random.nextBoolean() ? 1 : -1)
);
landingPosButBetter = CommandTravel.getLandingPosition(level, pos2);
if (Block.canSupportRigidBlock(level, landingPosButBetter.below())) {
recalc = true;
break;
}
}
}
}
if (Block.canSupportRigidBlock(level, landingPosButBetter.below())) {
loc.setPosition(landingPosButBetter.getX(), landingPosButBetter.getY(), landingPosButBetter.getZ());
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());
data.setTravelLocation(null);
data.setInFlight(false);
data.addFuel(-fuel);
data.save();
// if (!recalc) {
// sendResponse(player, "TARDIM is landing", CommandTardimBase.ResponseType.COMPLETE, source);
// } else {
// sendResponse(player, "Landing recalculated due to obstruction", CommandTardimBase.ResponseType.INFO, source);
// sendResponse(player, "TARDIM is landing", CommandTardimBase.ResponseType.COMPLETE, source);
// }
String level_str = "tardim:tardis_dimension";
this.tileEntity.getLevel().getServer().getLevel(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(level_str))).playSound(null, this.tileEntity.getPos(), (SoundEvent) TRDSounds.TARDIM_LANDING.get(), SoundSource.AMBIENT, 1.0F, 1.0F);
} else {
throw new LuaException("TARDIM landing obstructed. Aborting...");
}
} else {
throw new LuaException("TARDIM landing obstructed. Aborting...");
}
} else {
throw new LuaException("Not enough fuel for journey");
}
} else {
throw new LuaException("TARDIM is still taking off");
}
} else {
throw new LuaException("TARDIM has already landed");
}
}
/**
* Locate a biome
* @param biome_str String of the biome e.g. "minecraft:plains"
*/
@LuaFunction(mainThread = true)
public final void locateBiome(String biome_str) throws LuaException {
if (this.tileEntity.getLevel().isClientSide()) {
return;
}
TardimData data = getTardimData();
if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation()));
}
Optional<Biome> biome = this.tileEntity.getLevel().getServer()
.registryAccess()
.registryOrThrow(Registry.BIOME_REGISTRY)
.getOptional(new ResourceLocation(biome_str));
if (biome != null && biome.isPresent()) {
if (data.getTravelLocation() == null) {
data.setTravelLocation(new Location(data.getCurrentLocation()));
}
ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(data.getTravelLocation().getLevel());
BlockPos blockpos = new BlockPos(
data.getTravelLocation().getPos().getX(),
level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, data.getTravelLocation().getPos()).getY(),
data.getTravelLocation().getPos().getZ()
);
BlockPos blockpos1 = this.findNearestBiome(level, (Biome)biome.get(), blockpos, 6400, 8);
if (blockpos1 != null) {
data.getTravelLocation().setPosition(blockpos1.getX(), blockpos1.getY(), blockpos1.getZ());
data.save();
} else {
throw new LuaException("Biome not found");
}
} else {
throw new LuaException("Unknown biome");
}
}
/**
* Helper method to find a biome
* @param level ServerLevel to search
* @param biome Biome to find
* @param pos BlockPos to start from
* @param i Idk what this is, likely a radius
* @param j No idea about this either
* @return BlockPos of the biome
* @hidden
*/
public BlockPos findNearestBiome(ServerLevel level, Biome biome, BlockPos pos, int i, int j) {
Pair<BlockPos, Holder<Biome>> bb = level.getChunkSource()
.getGenerator()
.getBiomeSource()
.findBiomeHorizontal(
pos.getX(),
pos.getY(),
pos.getZ(),
i,
j,
b_val -> b_val.value() == biome,
level.random,
true,
level.getChunkSource().randomState().sampler()
);
return bb != null && bb.getFirst() != null ? (BlockPos)bb.getFirst() : null;
}
/**
* Set the skin of the TARDIM
* @param skin Skin name to change to
* @hidden
*/
@LuaFunction(mainThread = true)
public final void setSkin(String skin) throws LuaException {
if (this.tileEntity.getLevel().isClientSide()) {
return;
}
TardimData data = getTardimData();
ResourceLocation skinToApply = null;
Iterator var13 = TardimRegistry.getRegistry().keySet().iterator();
label39: {
ResourceLocation builder;
TardimRegistry.TardimBuilder b;
do {
if (!var13.hasNext()) {
break label39;
}
builder = (ResourceLocation)var13.next();
b = TardimRegistry.getTardimBuilder(builder);
} while(!b.getDisplayName().equalsIgnoreCase(skin) && !builder.toString().equalsIgnoreCase(skin));
skinToApply = builder;
}
if (skinToApply == null) {
throw new LuaException("Skin '" + skin + "' not found");
}
TardimData.Location loc = data.getCurrentLocation();
ServerLevel level = this.tileEntity.getLevel().getServer().getLevel(loc.getLevel());
data.setIdentifier(skinToApply);
// FakePlayer...
TardimRegistry.getTardimBuilder(skinToApply).changeTardimSkin(data, level, loc.getPos(), loc.getFacing(), new FakePlayer(this.tileEntity.getLevel(), this.tileEntity.getPos()));
}
/**
* 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.tileEntity.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);
}
/**
* Play cloister bell sound.
*/
@LuaFunction(mainThread = true)
public final void cloisterBell() throws LuaException {
if (this.tileEntity.getLevel().isClientSide()) {
return;
}
try {
Level lvl = this.tileEntity.getLevel();
if (!lvl.isClientSide) {
lvl.playSound(
null,
this.tileEntity.getPos(),
Registration.CLOISTER_SOUND.get(),
SoundSource.BLOCKS,
1.5f,
1f
);
}
} catch (Exception var9) {
throw new LuaException("There was an error trying to play the sound");
}
}
/**
* 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.tileEntity.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);
}
}

View file

@ -1,118 +0,0 @@
package su.a71.tardim_ic.tardim_ic.digital_interface;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import org.jetbrains.annotations.NotNull;
import su.a71.tardim_ic.tardim_ic.Registration;
import dan200.computercraft.api.peripheral.IPeripheral;
import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
public class DigitalInterfaceTileEntity extends BlockEntity implements IDigitalInterfaceEntity {
public TardimData data; // Our TARDIM
public DigitalInterfaceTileEntity(BlockPos pos, BlockState state) {
super(Registration.DIGITAL_TARDIM_INTERFACE_TILEENTITY.get(), pos, state);
this.data = getTardimDataInitial();
}
/**
* Our peripheral, we create a new peripheral for each new tile entity
*/
protected DigitalInterfacePeripheral peripheral = new DigitalInterfacePeripheral(this);
private LazyOptional<IPeripheral> peripheralCap;
public BlockPos getPos() {
return this.worldPosition;
}
@Override
public TardimData getTardim() {
return this.data;
}
/**
* When a computer modem tries to wrap our block, the modem will call getCapability to receive our peripheral.
* Then we just simply return a {@link LazyOptional} with our Peripheral
*/
@Override
@NotNull
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, Direction direction) {
if (cap == CAPABILITY_PERIPHERAL) {
if (peripheralCap == null) {
peripheralCap = LazyOptional.of(() -> peripheral);
}
return peripheralCap.cast();
}
return super.getCapability(cap, direction);
}
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();
}
}

View file

@ -1,89 +0,0 @@
package su.a71.tardim_ic.tardim_ic.digital_interface;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimManager;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
public class FakeDigitalInterfaceTileEntity implements IDigitalInterfaceEntity {
public BlockPos blockPos;
public Level level;
public TardimData data; // Our TARDIM
FakeDigitalInterfaceTileEntity(BlockPos in_block, Level in_level) {
this.blockPos = in_block;
this.level = in_level;
this.data = getTardimDataInitial();
}
@Override
public BlockPos getPos() {
return this.blockPos;
}
@Override
public Level getLevel() {
return this.level;
}
@Override
public TardimData getTardim() {
return this.data;
}
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;
}
}

View file

@ -1,12 +0,0 @@
package su.a71.tardim_ic.tardim_ic.digital_interface;
import com.swdteam.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();
}

View file

@ -1,18 +0,0 @@
package su.a71.tardim_ic.tardim_ic.mixin;
import org.spongepowered.asm.mixin.Mixin;
import com.swdteam.common.init.CommandManager;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import su.a71.tardim_ic.tardim_ic.registration.CommandInit;
// TARDIM loads commands a bit later on Forge, so we have to use mixins for this :/
@Mixin(value = CommandManager.class, remap = false)
public abstract class Commands {
@Inject(method="init()V", at=@At("TAIL"))
private static void init(CallbackInfo ci) {
CommandInit.init();
System.out.println("TARDIM: IC added commands using mixin");
}
}

View file

@ -1,102 +0,0 @@
package su.a71.tardim_ic.tardim_ic.redstone_input;
import com.swdteam.common.block.BlockBaseTardimPanel;
import com.swdteam.common.init.TRDDimensions;
import com.swdteam.common.init.TRDSounds;
import com.swdteam.network.NetworkHandler;
import com.swdteam.network.packets.PacketOpenEditGui;
import com.swdteam.tardim.TardimData;
import com.swdteam.tardim.TardimManager;
import com.swdteam.tileentity.TileEntityBaseTardimPanel;
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.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
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 net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import su.a71.tardim_ic.tardim_ic.Registration;
import su.a71.tardim_ic.tardim_ic.utils.FakePlayer;
public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBlock {
public RedstoneInputBlock() {
super(Properties.of(Material.METAL).strength(2, 4).noOcclusion());
}
@Nullable
@Override
public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
return Registration.REDSTONE_TARDIM_INPUT_TILEENTITY.get().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((Player)null, blockPos, (SoundEvent) TRDSounds.TARDIM_BEEP.get(), SoundSource.BLOCKS, 0.3F, 0.5F);
BlockEntity be = w.getBlockEntity(blockPos);
if (be instanceof TileEntityBaseTardimPanel && w.dimension() == TRDDimensions.TARDIS) {
TardimData data = TardimManager.getFromPos(blockPos);
if (data != null && data.hasPermission(player)) {
((RedstoneInputTileEntity) be).lastPlayer = player.getGameProfile().getId();
NetworkHandler.sendTo((ServerPlayer)player, new PacketOpenEditGui(1, blockPos));
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;
}
public void neighborChanged(BlockState blockState, Level level, BlockPos blockPos, Block block, BlockPos fromPos, boolean isMoving) {
DebugPackets.sendNeighborsUpdatePacket(level, blockPos);
BlockEntity be = level.getBlockEntity(blockPos);
if (!(be instanceof RedstoneInputTileEntity)) {
return;
}
// get redstone signal
Direction direction = blockState.getValue(FACING);
int redstoneSignal = level.getSignal(blockPos, direction);
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 && ((RedstoneInputTileEntity) be).lastPlayer != null) {
if (((TileEntityBaseTardimPanel)be).hasCommand()) {
((TileEntityBaseTardimPanel)be).execute(new FakePlayer(level, blockPos, ((RedstoneInputTileEntity) be).lastPlayer));
}
}
}
} else if (redstoneSignal == 0 && ((RedstoneInputTileEntity) be).isPowered)
((RedstoneInputTileEntity) be).isPowered = false;
}
}

View file

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

View file

@ -1,17 +0,0 @@
package su.a71.tardim_ic.tardim_ic.registration;
import su.a71.tardim_ic.tardim_ic.command.CommandListBiomes;
import su.a71.tardim_ic.tardim_ic.command.CommandListDimensions;
import su.a71.tardim_ic.tardim_ic.command.CommandModemTransmit;
import su.a71.tardim_ic.tardim_ic.command.CommandCloisterBell;
import com.swdteam.common.init.CommandManager;
public class CommandInit {
public static void init() {
CommandManager.register(new CommandModemTransmit());
CommandManager.register(new CommandCloisterBell());
CommandManager.register(new CommandListBiomes());
CommandManager.register(new CommandListDimensions());
}
}

View file

@ -1,48 +1,28 @@
modLoader = "javafml" #mandatory
loaderVersion="[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license = "MIT"
loaderVersion = "[46,)" #mandatory This is typically bumped every Minecraft version by Forge. See https://files.minecraftforge.net/ for a list of versions.
license = "C0-1.0" # Review your options at https://choosealicense.com/.
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
[[mods]] #mandatory
# The modid of the mod
modId = "tardim_ic" #mandatory
version = "1.2" #mandatory
# A display name for the mod
displayName = "TARDIM: In Control" #mandatory
# The description text for the mod (multi line!) (#mandatory)
modId = "multiloader" #mandatory
version = "${file.jarVersion}" #mandatory
displayName = "${mod_name}" #mandatory
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/)
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI)
logoFile = "multiloader.png" #optional (needs to be in the root of your mod jar (root of your 'resources' folder))
credits = "Thanks for this example mod goes to Java" #optional
authors = "${mod_author}" #optional
description = '''
All of time and space, now automated and improved. This mod aims to make TARDIM even better.
'''
logoFile = "icon.png"
authors = "Andrew_7_1"
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.tardim_ic]] #optional
# the modid of the dependency
This is a long form description of the mod. You can write whatever you want here
''' #mandatory (Supports multiline text)
[[dependencies.multiloader]] #optional
modId = "forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory = true #mandatory
# The version range of the dependency
versionRange="[43,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering = "NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
side = "BOTH"
# Here's another dependency
[[dependencies.tardim_ic]]
modId = "computercraft"
mandatory = true
versionRange = "1.95.3"
ordering = "NONE"
side = "BOTH"
[[dependencies.tardim_ic]]
modId = "tardim"
mandatory = true
versionRange = "1.2.2"
ordering = "AFTER"
side = "BOTH"
[[dependencies.tardim_ic]]
versionRange = "[46,)" #mandatory
ordering = "NONE" # The order that this dependency should load in relation to your mod, required to be either 'BEFORE' or 'AFTER' if the dependency is not mandatory
side = "BOTH" # Side this dependency is applied on - 'BOTH', 'CLIENT' or 'SERVER'
[[dependencies.multiloader]]
modId = "minecraft"
mandatory = true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange = "1.19.2"
versionRange = "[1.20,1.21)"
ordering = "NONE"
side = "BOTH"

View file

@ -0,0 +1 @@
com.example.examplemod.platform.ForgePlatformHelper

View file

@ -0,0 +1,17 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.example.examplemod.mixin",
"refmap": "${mod_id}.refmap.json",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"MixinTitleScreen"
],
"server": [
],
"injectors": {
"defaultRequire": 1
}
}

View file

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

View file

@ -8,7 +8,6 @@
return new ResourceLocation("tutorial", "tardim_dimension_lookup");
}
5.1 Forge's MANIFEST.MF too!
6. Panel buttons might still be broken on 1.2.2 1.19.2
Andrew71's proposals:
1. Quick-return command

5
TODO Normal file
View file

@ -0,0 +1,5 @@
== TODO for v1.2 ==
(Yes we had a lot of these)
* Good-looking documentation (MKDocs maybe?) hosted on https://tardim.a71.su
* Full 1.20 port

View file

@ -1,95 +0,0 @@
TODO for 1.2 and beyond
re-written 21.06.23
NEW ====================
Blocks:
Cartridge Loader
2 buttons, one to load information from a cartridge, another to write it.
Has a slot where when r-clicked with a cartridge inserts it/Takes it out
TARDIM Dock
Has a GUI, where you can configure:
* Name/id
* Landing facing
* White/Blacklist of users who can land
* (Potentially) Fallback id if this one is disabled
When configured, a CC method/TARDIM command can take you to it
When powered by a lever, no TARDIM can land (and potentially take off)
Food Machine
2 buttons. One changed chosen food (hopefully shown on screen), another throws it out.
Uses a bit of fuel but you get FOOD!
Items
Personal Jammer
When worn, other players are unable to locate the user with /locate command
Location cartridge
Contains coordinates, dimension of place and date when it was written to (potentially other metadata using CC)
Can be locked like a map
Potentially can be inserted into a disk drive peripheral
Compat:
CC:
* Look into what other things can be improved, how to automate doc creation
* Add creative digital TARDIM interface... (maybe remove TARDIM from item name?)
* Add a craftable treasure disk with pre-installed useful programs
Create:
Update to 0.5.1, add more display sources
Code:
Datapack-driven way to control where a TARDIM can land and at what price.
Achievements:
(need to decide on root)
"Nobody needs soup more than me"
Get soup from TARDIM's food machine
"Power of the Redstone"
Activate a redstone input
"From Russia with love"
Set exterior to Soviet Chronobox (or any other potential USSR-themed exteriors)
"Cyber-Upgrade"
Craft a digital interface
"???"
Register a dock
"It appears to be... jammed!"
"I've lost the bleeps, I lost the sweeps, and I lost the creeps."
Put on a location jammer
"I will always remember..."
Save (or maybe lock like a map?) a location cartridge
UPDATES ================
Blocks:
Redstone TARDIM Interface - add powered blockstate
(TARDIM) Fuel Storage - add comparator output based on fuel (0 - 9 I think)
(TARDIM) Time Rotor - add comparator/redstone output when in flight
Code:
Add config&datapack support (e.g. disable compat, more food machine food, only getters from digital interface)
Make 1WTC fix package names on forge and further improve multi-loader structure
(so that it's not just Fabric to Forge translation at last second).
Overall some code from TARDIM: IC might make its way into TARDIM hopefully
Try to smash all TODOs and warnings
Outside appearance:
Make a proper wiki/docs with CC methods, item recipes and explanations. Maybe even technical things.
Update README and Modrinth/Curse pages
Look into re-licensing and/or making proper public facing source code
Improve Discord server
Improve/Change icon
Make background image for modrinth
LOOK INTO ==============
Things to overall re-search
* Applications for SWD Discord moderator. Could be a path to actually getting the bloody source code access
* Making TARDIM doors sync between TARDIM and external dimension
* Some kind of CC scanner method to see the outside (and?) GUI panel that lets you see said outside (or pre-installed iso. program)
see: dev9551's isometric renderer (or pine3d)
* Advanced drive/fuel storage for interstellar travel. Like a "stores 10000 fuel but you have to use it at once"
* Change block appearance based on item name when placed (like Supplementaries)
* More Create compat: engine powered by tardim fuel and way to "wind up" the TARDIM
* (Likely only if access to TARDIM source) Weblate for localisation
* Possibly an enchantment that works same as personal jammer

View file

@ -1,5 +1,11 @@
subprojects {
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT' apply(false)
id 'net.minecraftforge.gradle' version '[6.0,6.2)' apply(false)
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply(false)
id("org.spongepowered.mixin") version "0.7-SNAPSHOT" apply(false)
}
subprojects {
apply plugin: 'java'
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
@ -19,7 +25,7 @@ subprojects {
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_author,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Timestamp' : System.currentTimeMillis(),
'Timestamp' : System.currentTimeMillis(),
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Built-On-Minecraft' : minecraft_version
])
@ -33,33 +39,42 @@ subprojects {
}
repositories {
mavenCentral()
maven {
name = 'Sponge / Mixin'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'BlameJared Maven (CrT / Bookshelf)'
name = 'BlameJared Maven (JEI / CraftTweaker / Bookshelf)'
url = 'https://maven.blamejared.com'
}
maven { url 'https://squiddev.cc/maven/' }
maven { url "https://cursemaven.com"}
// CC: Tweaked
maven {
url "https://squiddev.cc/maven/"
content {
includeGroup("cc.tweaked")
includeModule("org.squiddev", "Cobalt")
}
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.release = 17
it.options.getRelease().set(17)
}
processResources {
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'mods.toml', '*.mixins.json']) {
expand project.properties
}
}
// Disables Gradle's custom module metadata from being published to maven. The
// metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers.
tasks.withType(GenerateModuleMetadata) {
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}

View file

@ -3,18 +3,14 @@ version=1.2
group=su.a71.tardim_ic
# Common
minecraft_version=1.19.2
common_runs_enabled=false
common_client_run_name=Common Client
common_server_run_name=Common Server
minecraft_version=1.20
# Forge
forge_version=43.1.30
//forge_ats_enabled=true
forge_version=46.0.12
# Fabric
fabric_version=0.62.0+1.19.2
fabric_loader_version=0.14.10
fabric_version=0.83.0+1.20
fabric_loader_version=0.14.21
# Mod options
mod_name=tardim_in_control
@ -25,4 +21,4 @@ mod_id=tardim_ic
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
cc_version=1.100.9
cc_version=1.105.0

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