diff --git a/build.gradle b/build.gradle index 834dab3..95552ac 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'maven-publish' version = "${minecraft_version}-${mod_version}" group = 'com.vandendaelen.handles' // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = "${project.jar_name}_${minecraft_version}-${mod_version}" +archivesBaseName = "${project.jar_name}" sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. diff --git a/gradle.properties b/gradle.properties index 7c32503..0466424 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,11 +2,11 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -jar_name=Handles +jar_name=handles minecraft_version=1.14.4 -mod_version = "0.0.1" +mod_version = 0.0.1 # Deps jei_version=6.0.0.10 cct_version=1.86.2 -tm_tag=1.1.1 +tm_tag=1.0 diff --git a/src/main/java/com/vandendaelen/handles/blocks/tiles/TardisInterfaceTile.java b/src/main/java/com/vandendaelen/handles/blocks/tiles/TardisInterfaceTile.java index 02b87f2..ef6ab2c 100644 --- a/src/main/java/com/vandendaelen/handles/blocks/tiles/TardisInterfaceTile.java +++ b/src/main/java/com/vandendaelen/handles/blocks/tiles/TardisInterfaceTile.java @@ -10,6 +10,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.tardis.mod.controls.RefuelerControl; import net.tardis.mod.dimensions.TDimensions; import net.tardis.mod.tileentities.ConsoleTile; @@ -47,18 +48,35 @@ public Object[] getTardisDestination() throws NotATardisException{ return new Object[]{pos.getX(), pos.getY(), pos.getZ()}; } - public Object[] setTardisDestination(int x, int y, int z) throws NotATardisException{ + public Object[] setTardisDestination(double x, double y, double z) throws NotATardisException{ ConsoleTile tardis = getTardis(); - tardis.setDestination(tardis.getDestinationDimension(), new BlockPos(x, y, z)); + if (!tardis.isInFlight()) + tardis.setDestination(tardis.getDestinationDimension(), new BlockPos(x, y, z)); return null; } - public Object[] setTardisDimensionDestination(int id) throws NotATardisException { + public Object[] setTardisDimensionDestination(double id) throws NotATardisException { ConsoleTile tardis = getTardis(); - tardis.setDestination(DimensionHelper.getDimension(id), tardis.getDestination()); + if (!tardis.isInFlight()) + tardis.setDestination(DimensionHelper.getDimension((int)id), tardis.getDestination()); return null; } + public Object[] startTardisFlight() throws NotATardisException { + ConsoleTile tardis = getTardis(); + if (!tardis.isInFlight()) + tardis.takeoff(); + return null; + } + + public Object[] setTardisRefuelMode(boolean status) throws NotATardisException { + ConsoleTile tardis = getTardis(); + tardis.getControl(RefuelerControl.class).setRefuling(status); + return null; + } + + + public Object[] getDimensions(){ return DimensionHelper.getPrettyDimensionList().toArray(); } diff --git a/src/main/java/com/vandendaelen/handles/helpers/DimensionHelper.java b/src/main/java/com/vandendaelen/handles/helpers/DimensionHelper.java index 9a0e2bc..d17ab4d 100644 --- a/src/main/java/com/vandendaelen/handles/helpers/DimensionHelper.java +++ b/src/main/java/com/vandendaelen/handles/helpers/DimensionHelper.java @@ -1,8 +1,8 @@ package com.vandendaelen.handles.helpers; import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.server.ServerWorld; -import net.minecraftforge.fml.server.ServerLifecycleHooks; +import net.minecraftforge.common.DimensionManager; +import net.tardis.mod.helper.Helper; import java.text.MessageFormat; import java.util.ArrayList; @@ -10,14 +10,15 @@ public class DimensionHelper { public static DimensionType getDimension(int id){ - ArrayList worlds = new ArrayList<>(); - ServerLifecycleHooks.getCurrentServer().getWorlds().iterator().forEachRemaining(worlds::add); - return worlds.get(id).getDimension().getType(); + return getTardisableDimensionList().get(id); } public static ArrayList getPrettyDimensionList(){ - ArrayList worlds = new ArrayList<>(); - ServerLifecycleHooks.getCurrentServer().getWorlds().iterator().forEachRemaining(worlds::add); - return (ArrayList) worlds.stream().map(w -> MessageFormat.format("{0} - {1}", worlds.indexOf(w), w.getDimension().getType().getRegistryName().getNamespace())).collect(Collectors.toList()); + ArrayList dimensions = getTardisableDimensionList(); + return (ArrayList) dimensions.stream().map(dim -> MessageFormat.format("{0} - {1}", dimensions.indexOf(dim), dim.getRegistryName().toString())).collect(Collectors.toList()); + } + + public static ArrayList getTardisableDimensionList(){ + return (ArrayList) DimensionManager.getRegistry().stream().filter(Helper::canTravelToDimension).collect(Collectors.toList()); } } diff --git a/src/main/java/com/vandendaelen/handles/misc/TardisInterfacePeripheral.java b/src/main/java/com/vandendaelen/handles/misc/TardisInterfacePeripheral.java index 87f2239..4340a66 100644 --- a/src/main/java/com/vandendaelen/handles/misc/TardisInterfacePeripheral.java +++ b/src/main/java/com/vandendaelen/handles/misc/TardisInterfacePeripheral.java @@ -32,7 +32,9 @@ public String[] getMethodNames() { "getDestination", "setDestination", "setDimension", - "getDimensions" + "getDimensions", + "startFlight", + "setRefuel" }; } @@ -46,11 +48,15 @@ public Object[] callMethod(@Nonnull IComputerAccess iComputerAccess, @Nonnull IL case 1://getDestination return tile.getTardisDestination(); case 2://setDestination - return tile.setTardisDestination((int)objects[0], (int)objects[1], (int)objects[2]); - case 3: - return tile.setTardisDimensionDestination((int)objects[0]); - case 4: + return tile.setTardisDestination((double)objects[0], (double)objects[1], (double)objects[2]); + case 3://setDimension + return tile.setTardisDimensionDestination((double)objects[0]); + case 4://getDimensions return tile.getDimensions(); + case 5://startFlight + return tile.startTardisFlight(); + case 6://setRefuel + return tile.setTardisRefuelMode((boolean)objects[0]); default: return null; } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 7484b32..1511d87 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -18,7 +18,7 @@ displayURL="https://github.com/LotuxPunk/Handles" #optional # A file name (in the root of the mod JAR) containing a logo for display logoFile="handles.png" #optional # A text field displayed in the mod UI -credits="The New TARDIS Mod team" #optional +credits="The New TARDIS Mod team, TheVale (Tardis Interface model & texture)" #optional # A text field displayed in the mod UI authors="LotuxPunk" #optional # The description text for the mod (multi line!) (#mandatory)