diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2c770e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# eclipse +bin +*.launch +.settings +.metadata +.classpath +.project + +# idea +out +*.ipr +*.iws +*.iml +.idea + +# gradle +build +.gradle + +# other +eclipse +run diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..f6dccee --- /dev/null +++ b/build.gradle @@ -0,0 +1,47 @@ +buildscript { + repositories { + jcenter() + maven { url = "http://files.minecraftforge.net/maven" } + } + dependencies { + classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT' + } +} +apply plugin: 'net.minecraftforge.gradle.forge' + +version = "1.0" +group = "tschipp.carryon" +archivesBaseName = "carryon" + +sourceCompatibility = targetCompatibility = '1.8' +compileJava { + sourceCompatibility = targetCompatibility = '1.8' +} + +minecraft { + version = "1.11.2-13.20.1.2386" + runDir = "run" + + mappings = "snapshot_20161220" + // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. +} + +dependencies { + +} + +processResources { + + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + + expand 'version':project.version, 'mcversion':project.minecraft.version + } + + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..e9b9fd5 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +# Sets default memory used for gradle commands. Can be overridden by user or command line properties. +# This is required to provide enough memory for the Minecraft decompilation process. +org.gradle.jvmargs=-Xmx3G diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..30d399d Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e18cba7 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Sep 14 12:28:28 PDT 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..91a7e26 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/setup.bat b/setup.bat new file mode 100644 index 0000000..a2b532d --- /dev/null +++ b/setup.bat @@ -0,0 +1,2 @@ +gradlew setupDecompWorkspace && gradlew eclipse +pause \ No newline at end of file diff --git a/src/main/java/tschipp/carryon/CarryOn.java b/src/main/java/tschipp/carryon/CarryOn.java new file mode 100644 index 0000000..d39d3aa --- /dev/null +++ b/src/main/java/tschipp/carryon/CarryOn.java @@ -0,0 +1,53 @@ +package tschipp.carryon; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.Mod.Instance; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLConstructionEvent; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import tschipp.carryon.common.CommonProxy; + +@EventBusSubscriber +@Mod(modid = CarryOn.MODID, name = CarryOn.NAME, version = CarryOn.VERSION, guiFactory = "tschipp.carryon.client.gui.GuiFactoryCarryOn", dependencies = "required-after:forge@[13.20.1.2386,)") +public class CarryOn { + + @SidedProxy(clientSide = "tschipp.carryon.client.ClientProxy", serverSide = "tschipp.carryon.common.CommonProxy") + public static CommonProxy proxy; + + // Instance + @Instance(CarryOn.MODID) + public static CarryOn instance; + + public static final String MODID = "carryon"; + public static final String VERSION = "1.0"; + public static final String NAME = "Carry On"; + + //public static SimpleNetworkWrapper network; + + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + CarryOn.proxy.preInit(event); + } + + @EventHandler + public void init(FMLInitializationEvent event) { + CarryOn.proxy.init(event); + } + + @EventHandler + public void postInit(FMLPostInitializationEvent event) { + CarryOn.proxy.postInit(event); + } + +} \ No newline at end of file diff --git a/src/main/java/tschipp/carryon/client/ClientProxy.java b/src/main/java/tschipp/carryon/client/ClientProxy.java new file mode 100644 index 0000000..5986f60 --- /dev/null +++ b/src/main/java/tschipp/carryon/client/ClientProxy.java @@ -0,0 +1,30 @@ +package tschipp.carryon.client; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import tschipp.carryon.common.CommonProxy; +import tschipp.carryon.common.handler.RegistrationHandler; + +public class ClientProxy extends CommonProxy { + + @Override + public void preInit(FMLPreInitializationEvent event) + { + super.preInit(event); + RegistrationHandler.regItemRenders(); + RegistrationHandler.regClientEvents(); + } + + @Override + public void init(FMLInitializationEvent event) + { + super.init(event); + } + + @Override + public void postInit(FMLPostInitializationEvent e) + { + super.postInit(e); + } +} diff --git a/src/main/java/tschipp/carryon/client/event/RenderEvents.java b/src/main/java/tschipp/carryon/client/event/RenderEvents.java new file mode 100644 index 0000000..669b5f9 --- /dev/null +++ b/src/main/java/tschipp/carryon/client/event/RenderEvents.java @@ -0,0 +1,204 @@ +package tschipp.carryon.client.event; + +import java.lang.reflect.Field; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.client.event.RenderHandEvent; +import net.minecraftforge.client.event.RenderPlayerEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import tschipp.carryon.common.config.CarryOnConfig; +import tschipp.carryon.common.handler.RegistrationHandler; +import tschipp.carryon.common.item.ItemTile; + +public class RenderEvents +{ + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onScroll(MouseEvent event) + { + if (event.getDwheel() > 0 || event.getDwheel() < 0) + { + ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand(); + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile) + { + if (ItemTile.hasTileData(stack)) + event.setCanceled(true); + } + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onGuiOpen(GuiOpenEvent event) + { + if (event.getGui() != null) + { + boolean inventory = event.getGui() instanceof GuiContainer; + EntityPlayer player = Minecraft.getMinecraft().player; + if (player != null) + { + ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND); + if (inventory && !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) + { + event.setCanceled(true); + Minecraft.getMinecraft().currentScreen = null; + } + } + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void inputEvent(InputEvent event) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException + { + GameSettings settings = Minecraft.getMinecraft().gameSettings; + Field field = KeyBinding.class.getDeclaredField("pressed"); + field.setAccessible(true); + ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand(); + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) + { + if (settings.keyBindDrop.isPressed()) + { + field.set(settings.keyBindDrop, false); + } + if (settings.keyBindSwapHands.isPressed()) + { + field.set(settings.keyBindSwapHands, false); + } + for (KeyBinding keyBind : settings.keyBindsHotbar) + { + if (keyBind.isPressed()) + { + field.set(keyBind, false); + } + } + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void renderHand(RenderHandEvent event) + { + + World world = Minecraft.getMinecraft().world; + EntityPlayer player = Minecraft.getMinecraft().player; + ItemStack stack = player.getHeldItemMainhand(); + int pass = event.getRenderPass(); + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) + { + Block block = ItemTile.getBlock(stack); + BlockPos pos = player.getPosition(); + stack = ItemTile.getItemStack(stack); + + int light = world.getLight(player.getPosition()); + int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView; + + GlStateManager.pushMatrix(); + GlStateManager.scale(2.5, 2.5, 2.5); + + GlStateManager.translate(0, -0.5, -1); + + if (CarryOnConfig.settings.facePlayer ? !isChest(block) : isChest(block)) + { + GlStateManager.rotate(180, 0, 1f, 0); + GlStateManager.rotate(-15, 1f, 0, 0); + } + else + GlStateManager.rotate(15, 1f, 0, 0); + + RenderHelper.enableStandardItemLighting(); + + if (perspective == 0) + Minecraft.getMinecraft().getRenderItem().renderItem(stack, Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, world, player)); + GlStateManager.scale(1, 1, 1); + GlStateManager.popMatrix(); + + event.setCanceled(true); + + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onPlayerRenderPost(RenderPlayerEvent.Post event) + { + World world = Minecraft.getMinecraft().world; + EntityPlayer player = Minecraft.getMinecraft().player; + ItemStack stack = player.getHeldItemMainhand(); + + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) + { + Block block = ItemTile.getBlock(stack); + stack = ItemTile.getItemStack(stack); + + EntityItem entityItem = new EntityItem(Minecraft.getMinecraft().world, 0, 0, 0); + entityItem.hoverStart = 0; + + entityItem.setEntityItemStack(stack); + float rotation = -player.renderYawOffset; + int perspective = Minecraft.getMinecraft().gameSettings.thirdPersonView; + + GlStateManager.pushMatrix(); + GlStateManager.scale(2.2, 2.2, 2.2); + + if (CarryOnConfig.settings.facePlayer ? !isChest(block) : isChest(block)) + { + GlStateManager.rotate(rotation, 0, 1.0f, 0); + GlStateManager.translate(0, 0.1, 0.2); + } + else + { + GlStateManager.rotate(rotation + 180, 0, 1.0f, 0); + GlStateManager.translate(0, 0.1, -0.2); + } + + if (player.isSneaking()) + GlStateManager.translate(0, -0.08, 0); + + Minecraft.getMinecraft().getRenderManager().doRenderEntity(entityItem, event.getX(), event.getY(), event.getZ(), 0, 0, true); + GlStateManager.scale(1, 1, 1); + GlStateManager.popMatrix(); + + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onPlayerRenderPre(RenderPlayerEvent.Pre event) + { + EntityPlayer player = Minecraft.getMinecraft().player; + ItemStack stack = player.getHeldItemMainhand(); + RenderPlayer renderer = event.getRenderer(); + + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) + { + + } + } + + private boolean isChest(Block block) + { + return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST; + } + +} diff --git a/src/main/java/tschipp/carryon/client/gui/GuiConfigCarryOn.java b/src/main/java/tschipp/carryon/client/gui/GuiConfigCarryOn.java new file mode 100644 index 0000000..d09828c --- /dev/null +++ b/src/main/java/tschipp/carryon/client/gui/GuiConfigCarryOn.java @@ -0,0 +1,48 @@ +package tschipp.carryon.client.gui; + +import java.util.List; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.IConfigElement; +import tschipp.carryon.CarryOn; +import tschipp.carryon.common.config.CarryOnConfig; + +public class GuiConfigCarryOn extends GuiConfig +{ + private static final String LANG_PREFIX = CarryOn.MODID + ".category."; + + public GuiConfigCarryOn(GuiScreen parent) { + super(parent, getConfigElements(), CarryOn.MODID, false, false, "Carry On Configuration"); + } + + private static List getConfigElements() { + + final Configuration configuration = CarryOnConfig.EventHandler.getConfiguration(); + + final ConfigCategory topLevelCategory = configuration.getCategory(Configuration.CATEGORY_GENERAL); + topLevelCategory.getChildren() + .forEach(configCategory -> configCategory.setLanguageKey(GuiConfigCarryOn.LANG_PREFIX + configCategory.getName())); + + return new ConfigElement(topLevelCategory).getChildElements(); + } + + @Override + public void initGui() { + super.initGui(); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawScreen(mouseX, mouseY, partialTicks); + } + + @Override + protected void actionPerformed(GuiButton button) { + super.actionPerformed(button); + } +} diff --git a/src/main/java/tschipp/carryon/client/gui/GuiFactoryCarryOn.java b/src/main/java/tschipp/carryon/client/gui/GuiFactoryCarryOn.java new file mode 100644 index 0000000..dd74b43 --- /dev/null +++ b/src/main/java/tschipp/carryon/client/gui/GuiFactoryCarryOn.java @@ -0,0 +1,47 @@ +package tschipp.carryon.client.gui; + +import java.util.Set; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.fml.client.IModGuiFactory; + +public class GuiFactoryCarryOn implements IModGuiFactory +{ + @Override + public void initialize(Minecraft minecraftInstance) { + // Do nothing + } + + @Override + public Class mainConfigGuiClass() { + return GuiConfigCarryOn.class; + } + + @Override + public Set runtimeGuiCategories() { + return null; + } + + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { + return null; + } + + + @Override + public boolean hasConfigGui() + { + return true; + } + + @Override + public GuiScreen createConfigGui(GuiScreen parentScreen) + { + + return new GuiConfigCarryOn(parentScreen); + } + + + +} \ No newline at end of file diff --git a/src/main/java/tschipp/carryon/common/CommonProxy.java b/src/main/java/tschipp/carryon/common/CommonProxy.java new file mode 100644 index 0000000..f0faac5 --- /dev/null +++ b/src/main/java/tschipp/carryon/common/CommonProxy.java @@ -0,0 +1,30 @@ +package tschipp.carryon.common; + +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import tschipp.carryon.CarryOn; +import tschipp.carryon.common.handler.RegistrationHandler; + +public class CommonProxy +{ + + @EventHandler + public void preInit(FMLPreInitializationEvent event) + { + RegistrationHandler.regItems(); + RegistrationHandler.regCommonEvents(); + } + + @EventHandler + public void init(FMLInitializationEvent event) + { + } + + @EventHandler + public void postInit(FMLPostInitializationEvent e) + { + } + +} diff --git a/src/main/java/tschipp/carryon/common/config/CarryOnConfig.java b/src/main/java/tschipp/carryon/common/config/CarryOnConfig.java new file mode 100644 index 0000000..060b26b --- /dev/null +++ b/src/main/java/tschipp/carryon/common/config/CarryOnConfig.java @@ -0,0 +1,90 @@ +package tschipp.carryon.common.config; + +import java.io.File; +import java.lang.invoke.MethodHandle; +import java.util.Map; +import java.util.Optional; + +import net.minecraftforge.common.config.Config; +import net.minecraftforge.common.config.ConfigManager; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.client.config.IConfigElement; +import net.minecraftforge.fml.client.event.ConfigChangedEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import tschipp.carryon.CarryOn; +import tschipp.carryon.common.helper.ReflectionUtil; + +@Config(modid = CarryOn.MODID) +public class CarryOnConfig { + + @Config.LangKey(CarryOn.MODID) + @Config.Comment("General Mod Settings") + public static Configs.Settings settings = new Configs.Settings(); + + @Config.LangKey(CarryOn.MODID) + @Config.Comment("Tile Entities that the Player is not allowed to pick up") + public static Configs.ForbiddenTiles forbiddenTiles = new Configs.ForbiddenTiles(); + + @Mod.EventBusSubscriber + public static class EventHandler { + + /** + * The {@link ConfigManager#CONFIGS} getter. + */ + private static final MethodHandle CONFIGS_GETTER = ReflectionUtil.findFieldGetter(ConfigManager.class, "CONFIGS"); + + + /** + * The {@link Configuration} instance. + */ + private static Configuration configuration; + + /** + * Get the {@link Configuration} instance from {@link ConfigManager}. + *

+ * TODO: Use a less hackish method of getting the + * {@link Configuration}/{@link IConfigElement}s when possible. + * + * @return The Configuration instance + */ + public static Configuration getConfiguration() { + if (EventHandler.configuration == null) + try { + final String fileName = CarryOn.MODID + ".cfg"; + + @SuppressWarnings("unchecked") + final Map configsMap = (Map) EventHandler.CONFIGS_GETTER + .invokeExact(); + + final Optional> entryOptional = configsMap.entrySet().stream() + .filter(entry -> fileName.equals(new File(entry.getKey()).getName())).findFirst(); + + entryOptional + .ifPresent(stringConfigurationEntry -> EventHandler.configuration = stringConfigurationEntry + .getValue()); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + + return EventHandler.configuration; + } + + /** + * Inject the new values and save to the config file when the config has + * been changed from the GUI. + * + * @param event + * The event + */ + @SubscribeEvent + public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { + if (event.getModID().equals(CarryOn.MODID)) + ConfigManager.load(CarryOn.MODID, Config.Type.INSTANCE); + + } + + } + +} diff --git a/src/main/java/tschipp/carryon/common/config/Configs.java b/src/main/java/tschipp/carryon/common/config/Configs.java new file mode 100644 index 0000000..d4508bd --- /dev/null +++ b/src/main/java/tschipp/carryon/common/config/Configs.java @@ -0,0 +1,45 @@ +package tschipp.carryon.common.config; + +import net.minecraftforge.common.config.Config; +import net.minecraftforge.common.config.Config.Comment; + +public class Configs { + + public static class Settings + { + @Comment("If the front of the Tile Entities should face the player or should face outward") + public boolean facePlayer = false; + + @Comment("More complex Tile Entities slow down the player more") + public boolean heavyTiles = false; + } + + public static class ForbiddenTiles + { + @Config.RequiresMcRestart() + @Comment("Tile Entities that cannot be picked up") + public String[] forbiddenTiles = new String[] + { + "animania:block_trough", + "animania:block_invisiblock", + "ic2:*", + "immersiveengineering:*", + "embers:block_furnace", + "embers:ember_bore", + "embers:ember_activator", + "embers:mixer", + "embers:heat_coil", + "embers:large_tank", + "embers:crystal_cell", + "embers:alchemy_pedestal", + "embers:boiler", + "embers:combustor", + "embers:catalzyer", + "embers:field_chart", + "embers:inferno_forge" + + }; + + } + +} diff --git a/src/main/java/tschipp/carryon/common/event/ItemEvents.java b/src/main/java/tschipp/carryon/common/event/ItemEvents.java new file mode 100644 index 0000000..89900f7 --- /dev/null +++ b/src/main/java/tschipp/carryon/common/event/ItemEvents.java @@ -0,0 +1,111 @@ +package tschipp.carryon.common.event; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.fml.common.eventhandler.Event.Result; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import tschipp.carryon.common.handler.ForbiddenTileHandler; +import tschipp.carryon.common.handler.RegistrationHandler; +import tschipp.carryon.common.item.ItemTile; + +public class ItemEvents +{ + + @SubscribeEvent(priority = EventPriority.HIGH) + public void onBlockClick(PlayerInteractEvent.RightClickBlock event) + { + EntityPlayer player = event.getEntityPlayer(); + ItemStack stack = player.getHeldItemMainhand(); + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) + { + event.setUseBlock(Result.DENY); + } + + } + + @SubscribeEvent(priority = EventPriority.HIGH) + public void onItemDropped(EntityJoinWorldEvent event) + { + Entity e = event.getEntity(); + World world = event.getWorld(); + if (e instanceof EntityItem) + { + EntityItem eitem = (EntityItem) e; + ItemStack stack = eitem.getEntityItem(); + Item item = stack.getItem(); + if (item == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) + { + BlockPos pos = eitem.getPosition(); + BlockPos finalPos = pos; + Block block = ItemTile.getBlock(stack); + if (!world.getBlockState(pos).getBlock().isReplaceable(world, pos) || !block.canPlaceBlockAt(world, pos)) + { + for (EnumFacing facing : EnumFacing.VALUES) + { + BlockPos offsetPos = pos.offset(facing); + if (world.getBlockState(offsetPos).getBlock().isReplaceable(world, offsetPos) && block.canPlaceBlockAt(world, offsetPos)) + { + finalPos = offsetPos; + break; + } + } + } + world.setBlockState(finalPos, ItemTile.getBlockState(stack)); + TileEntity tile = world.getTileEntity(finalPos); + tile.readFromNBT(ItemTile.getTileData(stack)); + tile.setPos(finalPos); + ItemTile.clearTileData(stack); + eitem.setEntityItemStack(ItemStack.EMPTY); + } + } + } + + + @SubscribeEvent + public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) + { + EntityPlayer player = event.getEntityPlayer(); + ItemStack main = player.getHeldItemMainhand(); + World world = event.getWorld(); + BlockPos pos = event.getPos(); + Block block = world.getBlockState(pos).getBlock(); + IBlockState state = world.getBlockState(pos); + + if (main.isEmpty() && player.isSneaking() && !ForbiddenTileHandler.isForbidden(block)) + { + ItemStack stack = new ItemStack(RegistrationHandler.itemTile); + + TileEntity te = world.getTileEntity(pos); + if (te != null && (block.getBlockHardness(state, world, pos) != -1 || player.isCreative())) + { + + if (!ItemTile.isLocked(pos, world)) + { + if (ItemTile.storeTileData(te, state, stack)) + { + world.removeTileEntity(pos); + world.setBlockToAir(pos); + player.setHeldItem(EnumHand.MAIN_HAND, stack); + event.setUseBlock(Result.DENY); + } + } + + } + + } + } + +} diff --git a/src/main/java/tschipp/carryon/common/handler/ForbiddenTileHandler.java b/src/main/java/tschipp/carryon/common/handler/ForbiddenTileHandler.java new file mode 100644 index 0000000..2193577 --- /dev/null +++ b/src/main/java/tschipp/carryon/common/handler/ForbiddenTileHandler.java @@ -0,0 +1,41 @@ +package tschipp.carryon.common.handler; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import tschipp.carryon.common.config.CarryOnConfig; + +public class ForbiddenTileHandler +{ + + public static final List FORBIDDEN_TILES; + + public static boolean isForbidden(Block block) + { + return FORBIDDEN_TILES.contains(block.getRegistryName().toString()); + } + + static + { + String[] forbidden = CarryOnConfig.forbiddenTiles.forbiddenTiles; + + FORBIDDEN_TILES = new ArrayList(); + + for(int i = 0; i < forbidden.length; i++) + { + if(forbidden[i].contains("*")) + { + String modid = forbidden[i].replace("*", ""); + for(int k = 0; k < Block.REGISTRY.getKeys().size(); k++) + { + if(Block.REGISTRY.getKeys().toArray()[k].toString().contains(modid)) + { + FORBIDDEN_TILES.add(Block.REGISTRY.getKeys().toArray()[k].toString()); + } + } + } + FORBIDDEN_TILES.add(forbidden[i]); + } + } +} diff --git a/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java b/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java new file mode 100644 index 0000000..64cc71d --- /dev/null +++ b/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java @@ -0,0 +1,36 @@ +package tschipp.carryon.common.handler; + +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.item.Item; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.common.MinecraftForge; +import tschipp.carryon.CarryOn; +import tschipp.carryon.client.event.RenderEvents; +import tschipp.carryon.common.event.ItemEvents; +import tschipp.carryon.common.item.ItemTile; + +public class RegistrationHandler +{ + public static Item itemTile; + + public static void regItems() + { + itemTile = new ItemTile(); + } + + public static void regItemRenders() + { + ModelLoader.setCustomModelResourceLocation(itemTile, 0, new ModelResourceLocation(CarryOn.MODID + ":" + "tile", "inventory")); + } + + public static void regCommonEvents() + { + MinecraftForge.EVENT_BUS.register(new ItemEvents()); + } + + public static void regClientEvents() + { + MinecraftForge.EVENT_BUS.register(new RenderEvents()); + } + +} diff --git a/src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java b/src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java new file mode 100644 index 0000000..6f7f376 --- /dev/null +++ b/src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java @@ -0,0 +1,76 @@ +package tschipp.carryon.common.helper; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import net.minecraftforge.fml.relauncher.ReflectionHelper; + +/** + * Utility methods for reflection. + * + * @author Choonster + */ +public class ReflectionUtil +{ + /** + * Get a {@link MethodHandle} for a method. + * + * @param clazz + * The class + * @param methodNames + * The possible names of the method + * @param methodTypes + * The argument types of the method + * @param + * The class + * @return The MethodHandle + */ + public static MethodHandle findMethod(Class clazz, String[] methodNames, Class... methodTypes) { + final Method method = ReflectionHelper.findMethod(clazz, null, methodNames, methodTypes); + try { + return MethodHandles.lookup().unreflect(method); + } catch (IllegalAccessException e) { + throw new ReflectionHelper.UnableToFindMethodException(methodNames, e); + } + } + + /** + * Get a {@link MethodHandle} for a field's getter. + * + * @param clazz + * The class + * @param fieldNames + * The possible names of the field + * @return The MethodHandle + */ + public static MethodHandle findFieldGetter(Class clazz, String... fieldNames) { + final Field field = ReflectionHelper.findField(clazz, fieldNames); + + try { + return MethodHandles.lookup().unreflectGetter(field); + } catch (IllegalAccessException e) { + throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e); + } + } + + /** + * Get a {@link MethodHandle} for a field's setter. + * + * @param clazz + * The class + * @param fieldNames + * The possible names of the field + * @return The MethodHandle + */ + public static MethodHandle findFieldSetter(Class clazz, String... fieldNames) { + final Field field = ReflectionHelper.findField(clazz, fieldNames); + + try { + return MethodHandles.lookup().unreflectSetter(field); + } catch (IllegalAccessException e) { + throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e); + } + } +} \ No newline at end of file diff --git a/src/main/java/tschipp/carryon/common/item/ItemTile.java b/src/main/java/tschipp/carryon/common/item/ItemTile.java new file mode 100644 index 0000000..7f3f55c --- /dev/null +++ b/src/main/java/tschipp/carryon/common/item/ItemTile.java @@ -0,0 +1,271 @@ +package tschipp.carryon.common.item; + +import java.util.Iterator; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockDirectional; +import net.minecraft.block.BlockHorizontal; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyDirection; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.MobEffects; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.PotionEffect; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.registry.GameRegistry; +import scala.actors.threadpool.Arrays; +import tschipp.carryon.CarryOn; +import tschipp.carryon.common.config.CarryOnConfig; + +public class ItemTile extends Item +{ + + public static final String TILE_DATA_KEY = "tileData"; + + public ItemTile() + { + this.setUnlocalizedName("tile_item"); + this.setRegistryName(CarryOn.MODID, "tile_item"); + GameRegistry.register(this); + this.setMaxStackSize(1); + } + + @Override + public String getItemStackDisplayName(ItemStack stack) + { + if (hasTileData(stack)) + { + return getItemStack(stack).getDisplayName(); + } + + return ""; + } + + @Override + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + { + Block block = world.getBlockState(pos).getBlock(); + ItemStack stack = player.getHeldItem(hand); + if (hasTileData(stack)) + { + Vec3d vec = player.getLookVec(); + EnumFacing facing2 = EnumFacing.getFacingFromVector((float) vec.xCoord, 0f, (float) vec.zCoord); + BlockPos pos2 = pos; + Block containedblock = getBlock(stack); + int meta = getMeta(stack); + if (!world.getBlockState(pos2).getBlock().isReplaceable(world, pos2)) + { + pos2 = pos.offset(facing); + } + + if (world.getBlockState(pos2).getBlock().isReplaceable(world, pos2)) + { + boolean canPlace = containedblock.canPlaceBlockAt(world, pos2); + + if (canPlace) + { + if (player.canPlayerEdit(pos, facing, stack) && world.mayPlace(containedblock, pos2, false, facing, (Entity) null)) + { + boolean hasDirection = false; + boolean hasAllDirection = false; + + Iterator> iterator = containedblock.getDefaultState().getPropertyKeys().iterator(); + while (iterator.hasNext()) + { + IProperty prop = iterator.next(); + Object[] allowedValues = prop.getAllowedValues().toArray(); + + if (prop instanceof PropertyDirection && this.equal(allowedValues, EnumFacing.HORIZONTALS)) + hasDirection = true; + + if(prop instanceof PropertyDirection && this.equal(allowedValues, EnumFacing.VALUES)) + { + hasAllDirection = true; + facing2 = EnumFacing.getFacingFromVector((float) vec.xCoord, (float) vec.yCoord, (float) vec.zCoord); + } + + } + + if(hasAllDirection) + world.setBlockState(pos2, containedblock.getStateFromMeta(meta).withProperty(BlockDirectional.FACING, facing2.getOpposite())); + else if (hasDirection) + world.setBlockState(pos2, containedblock.getStateFromMeta(meta).withProperty(BlockHorizontal.FACING, facing2.getOpposite())); + else + world.setBlockState(pos2, containedblock.getStateFromMeta(meta)); + + TileEntity tile = world.getTileEntity(pos2); + if (tile != null) + { + tile.readFromNBT(getTileData(stack)); + tile.setPos(pos2); + } + clearTileData(stack); + player.playSound(containedblock.getSoundType().getPlaceSound(), 1.0f, 0.5f); + player.setHeldItem(hand, ItemStack.EMPTY); + return EnumActionResult.SUCCESS; + } + + } + } + + } + + return EnumActionResult.FAIL; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) + { + if (hasTileData(stack)) + { + if (entity instanceof EntityLivingBase) + { + ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 1, potionLevel(stack), false, false)); + } + } + else + { + stack = ItemStack.EMPTY; + } + } + + public static boolean hasTileData(ItemStack stack) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound(); + return tag.hasKey(TILE_DATA_KEY) && tag.hasKey("block") && tag.hasKey("meta"); + } + return false; + } + + public static boolean storeTileData(TileEntity tile, IBlockState state, ItemStack stack) + { + if (tile == null) + return false; + + if (stack.isEmpty()) + return false; + + NBTTagCompound chest = new NBTTagCompound(); + chest = tile.writeToNBT(chest); + + NBTTagCompound tag = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound(); + if (tag.hasKey(TILE_DATA_KEY)) + return false; + + tag.setTag(TILE_DATA_KEY, chest); + + tag.setString("block", state.getBlock().getRegistryName().toString()); + Item item = Item.getItemFromBlock(state.getBlock()); + tag.setInteger("meta", item.getHasSubtypes() ? state.getBlock().getMetaFromState(state) : 0); + stack.setTagCompound(tag); + return true; + } + + public static void clearTileData(ItemStack stack) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound(); + tag.removeTag(TILE_DATA_KEY); + tag.removeTag("block"); + tag.removeTag("meta"); + + } + } + + public static NBTTagCompound getTileData(ItemStack stack) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound(); + return tag.getCompoundTag(TILE_DATA_KEY); + } + return null; + } + + public static Block getBlock(ItemStack stack) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound(); + String name = tag.getString("block"); + return Block.getBlockFromName(name); + } + return Blocks.AIR; + } + + public static int getMeta(ItemStack stack) + { + if (stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound(); + int meta = tag.getInteger("meta"); + return meta; + } + return 0; + } + + public static ItemStack getItemStack(ItemStack stack) + { + return new ItemStack(getBlock(stack), 1, getMeta(stack)); + } + + public static IBlockState getBlockState(ItemStack stack) + { + return getBlock(stack).getStateFromMeta(getMeta(stack)); + } + + + public static boolean isLocked(BlockPos pos, World world) + { + TileEntity te = world.getTileEntity(pos); + if(te != null) + { + NBTTagCompound tag = new NBTTagCompound(); + te.writeToNBT(tag); + return tag.hasKey("Lock") ? !tag.getString("Lock").equals("") : false; + } + + return true; + } + + private boolean equal(Object[] a, Object[] b) + { + if (a.length != b.length) + return false; + + List lA = Arrays.asList(a); + List lB = Arrays.asList(b); + + return lA.containsAll(lB); + } + + private int potionLevel(ItemStack stack) + { + String nbt = getTileData(stack).toString(); + int i = nbt.length() / 500; + + if(i > 4) + i = 4; + + if(!CarryOnConfig.settings.heavyTiles) + i = 1; + + return i; + } +} diff --git a/src/main/resources/assets/carryon/carryOn.png b/src/main/resources/assets/carryon/carryOn.png new file mode 100644 index 0000000..1b9a978 Binary files /dev/null and b/src/main/resources/assets/carryon/carryOn.png differ diff --git a/src/main/resources/assets/carryon/lang/en_US.lang b/src/main/resources/assets/carryon/lang/en_US.lang new file mode 100644 index 0000000..eb3cbf8 --- /dev/null +++ b/src/main/resources/assets/carryon/lang/en_US.lang @@ -0,0 +1,4 @@ +carryon.category.settings=Settings +carryon.category.forbiddentiles=Forbidden Tile Entities + +carryon.general.forbiddentiles.forbiddentiles=Tile Entities that the Player cannot pick up \ No newline at end of file diff --git a/src/main/resources/assets/carryon/models/item/tile.json b/src/main/resources/assets/carryon/models/item/tile.json new file mode 100644 index 0000000..3b02d83 --- /dev/null +++ b/src/main/resources/assets/carryon/models/item/tile.json @@ -0,0 +1,33 @@ +{ + "parent": "builtin/generated", + "textures": { + "layer0": "carryon:items/tile" + }, + "display": { + "ground": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 2, 0], + "scale":[ 0.5, 0.5, 0.5 ] + }, + "head": { + "rotation": [ 0, 180, 0 ], + "translation": [ 0, 13, 7], + "scale":[ 1, 1, 1] + }, + "thirdperson_righthand": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 0, 1 ], + "scale": [ 0.1, 0.1, 0.1 ] + }, + "firstperson_righthand": { + "rotation": [ 0, -90, 25 ], + "translation": [ 1.13, 3.2, 1.13], + "scale": [ 0.68, 0.68, 0.68 ] + }, + "gui": { + "rotation": [ 30, 225, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 0.625, 0.625, 0.625 ] + } + } +} diff --git a/src/main/resources/assets/carryon/textures/items/tile.png b/src/main/resources/assets/carryon/textures/items/tile.png new file mode 100644 index 0000000..98a6294 Binary files /dev/null and b/src/main/resources/assets/carryon/textures/items/tile.png differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info new file mode 100644 index 0000000..a94c846 --- /dev/null +++ b/src/main/resources/mcmod.info @@ -0,0 +1,16 @@ +[ +{ + "modid" : "carryon", + "name" : "Carry On", + "version" : "1.0", "mcversion" : "1.11.2", + "url" : "", + "credits" : "Game concept, creative direction, models, textures, animation, sound design, and development by RazzleberryFox, Purplicious_Cow, cy4n, Tschipp, ZeAmateis, Timmypote, vroulas, and TheJurassicAlien", + "authorList" : ["RazzleberryFox, Purplicious_Cow, cy4n, Tschipp, ZeAmateis, Timmypote, vroulas, and TheJurassicAlien"], + "description": "Immersive and realistic animals in Minecraft, with improved models, textures, animation, behaviors, and drops.", + "logoFile" : "assets/carryon/textures/logo.png", + "updateUrl" : "", + "parent" : "", + "dependencies": [], + "screenshots": [] +} +]